Compare commits
	
		
			3 Commits
		
	
	
		
			ad30583265
			...
			625e4b570b
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 625e4b570b | |
|  | 1fd1444f97 | |
|  | 38110bb19d | 
|  | @ -16,6 +16,14 @@ steps: | |||
|     tags: | ||||
|     - latest | ||||
|     - main | ||||
| - name: continuous deployment | ||||
|   image: alpine:latest | ||||
|   commands: | ||||
|   - apk add -y openssh | ||||
|   - sh deploy.sh | ||||
|   environment: | ||||
|     SSH_KEY: | ||||
|       from_secret: SSH_KEY | ||||
| trigger: | ||||
|   branch: | ||||
|   - main | ||||
|  |  | |||
							
								
								
									
										10
									
								
								api/serve.go
								
								
								
								
							
							
						
						
									
										10
									
								
								api/serve.go
								
								
								
								
							|  | @ -66,11 +66,19 @@ func IdContinuation(context *RequestContext, req *http.Request, resp http.Respon | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| func CacheControlMiddleware(next http.Handler, maxAge int) http.Handler { | ||||
| 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
| 		header := fmt.Sprintf("public, max-age=%d", maxAge) | ||||
| 		w.Header().Set("Cache-Control", header) | ||||
| 		next.ServeHTTP(w, r) | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| func MakeServer(argv *args.Arguments, dbConn *sql.DB) *http.Server { | ||||
| 	mux := http.NewServeMux() | ||||
| 
 | ||||
| 	fileServer := http.FileServer(http.Dir(argv.StaticPath)) | ||||
| 	mux.Handle("GET /static/", http.StripPrefix("/static/", fileServer)) | ||||
| 	mux.Handle("/static/", http.StripPrefix("/static/", CacheControlMiddleware(fileServer, 3600))) | ||||
| 
 | ||||
| 	makeRequestContext := func() *RequestContext { | ||||
| 		return &RequestContext{ | ||||
|  |  | |||
|  | @ -59,10 +59,17 @@ func MigrateDNSRecords(dbConn *sql.DB) (*sql.DB, error) { | |||
| 		ttl INTEGER NOT NULL, | ||||
|                 internal BOOLEAN NOT NULL, | ||||
| 		created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||||
| 		FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE);`) | ||||
| 		FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE | ||||
|         );`) | ||||
| 	if err != nil { | ||||
| 		return dbConn, err | ||||
| 	} | ||||
| 
 | ||||
| 	_, err = dbConn.Exec(`CREATE UNIQUE INDEX IF NOT EXISTS idx_dns_records_name_content_type ON dns_records (name, type, content);`) | ||||
| 	if err != nil { | ||||
| 		return dbConn, err | ||||
| 	} | ||||
| 
 | ||||
| 	return dbConn, nil | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue