Compare commits
No commits in common. "625e4b570b523e731aaca72a9c9d53eb0c5ad7af" and "ad30583265f838edd60f3ce2026db60de0f9df96" have entirely different histories.
625e4b570b
...
ad30583265
|
@ -16,14 +16,6 @@ steps:
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- main
|
- main
|
||||||
- name: continuous deployment
|
|
||||||
image: alpine:latest
|
|
||||||
commands:
|
|
||||||
- apk add -y openssh
|
|
||||||
- sh deploy.sh
|
|
||||||
environment:
|
|
||||||
SSH_KEY:
|
|
||||||
from_secret: SSH_KEY
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
|
|
10
api/serve.go
10
api/serve.go
|
@ -66,19 +66,11 @@ 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 {
|
func MakeServer(argv *args.Arguments, dbConn *sql.DB) *http.Server {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
|
||||||
fileServer := http.FileServer(http.Dir(argv.StaticPath))
|
fileServer := http.FileServer(http.Dir(argv.StaticPath))
|
||||||
mux.Handle("/static/", http.StripPrefix("/static/", CacheControlMiddleware(fileServer, 3600)))
|
mux.Handle("GET /static/", http.StripPrefix("/static/", fileServer))
|
||||||
|
|
||||||
makeRequestContext := func() *RequestContext {
|
makeRequestContext := func() *RequestContext {
|
||||||
return &RequestContext{
|
return &RequestContext{
|
||||||
|
|
|
@ -59,17 +59,10 @@ func MigrateDNSRecords(dbConn *sql.DB) (*sql.DB, error) {
|
||||||
ttl INTEGER NOT NULL,
|
ttl INTEGER NOT NULL,
|
||||||
internal BOOLEAN NOT NULL,
|
internal BOOLEAN NOT NULL,
|
||||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
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 {
|
if err != nil {
|
||||||
return dbConn, err
|
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
|
return dbConn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue