profiles #7
12
api/serve.go
12
api/serve.go
|
@ -71,16 +71,11 @@ func CacheControlMiddleware(next http.Handler, maxAge int) http.Handler {
|
||||||
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()
|
||||||
|
|
||||||
staticFileServer := http.FileServer(http.Dir(argv.StaticPath))
|
// "dependency injection"
|
||||||
uploadFileServer := http.FileServer(http.Dir(argv.UploadPath))
|
|
||||||
mux.Handle("GET /static/", http.StripPrefix("/static/", CacheControlMiddleware(staticFileServer, 3600)))
|
|
||||||
mux.Handle("GET /uploads/", http.StripPrefix("/uploads/", CacheControlMiddleware(uploadFileServer, 3600)))
|
|
||||||
|
|
||||||
cloudflareAdapter := &cloudflare.CloudflareExternalDNSAdapter{
|
cloudflareAdapter := &cloudflare.CloudflareExternalDNSAdapter{
|
||||||
APIToken: argv.CloudflareToken,
|
APIToken: argv.CloudflareToken,
|
||||||
ZoneId: argv.CloudflareZone,
|
ZoneId: argv.CloudflareZone,
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadAdapter := &filesystem.FilesystemAdapter{
|
uploadAdapter := &filesystem.FilesystemAdapter{
|
||||||
BasePath: argv.UploadPath,
|
BasePath: argv.UploadPath,
|
||||||
Permissions: 0777,
|
Permissions: 0777,
|
||||||
|
@ -94,6 +89,11 @@ func MakeServer(argv *args.Arguments, dbConn *sql.DB) *http.Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
staticFileServer := http.FileServer(http.Dir(argv.StaticPath))
|
||||||
|
uploadFileServer := http.FileServer(http.Dir(argv.UploadPath))
|
||||||
|
mux.Handle("GET /static/", http.StripPrefix("/static/", CacheControlMiddleware(staticFileServer, 3600)))
|
||||||
|
mux.Handle("GET /uploads/", http.StripPrefix("/uploads/", CacheControlMiddleware(uploadFileServer, 3600)))
|
||||||
|
|
||||||
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) {
|
||||||
requestContext := makeRequestContext()
|
requestContext := makeRequestContext()
|
||||||
LogRequestContinuation(requestContext, r, w)(auth.VerifySessionContinuation, FailurePassingContinuation)(IdContinuation, IdContinuation)(auth.ListUsersContinuation, auth.ListUsersContinuation)(template.TemplateContinuation("home.html", true), FailurePassingContinuation)(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation)
|
LogRequestContinuation(requestContext, r, w)(auth.VerifySessionContinuation, FailurePassingContinuation)(IdContinuation, IdContinuation)(auth.ListUsersContinuation, auth.ListUsersContinuation)(template.TemplateContinuation("home.html", true), FailurePassingContinuation)(LogExecutionTimeContinuation, LogExecutionTimeContinuation)(IdContinuation, IdContinuation)
|
||||||
|
|
Loading…
Reference in New Issue