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 { | ||||
| 	mux := http.NewServeMux() | ||||
| 
 | ||||
| 	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))) | ||||
| 
 | ||||
| 	// "dependency injection"
 | ||||
| 	cloudflareAdapter := &cloudflare.CloudflareExternalDNSAdapter{ | ||||
| 		APIToken: argv.CloudflareToken, | ||||
| 		ZoneId:   argv.CloudflareZone, | ||||
| 	} | ||||
| 
 | ||||
| 	uploadAdapter := &filesystem.FilesystemAdapter{ | ||||
| 		BasePath:    argv.UploadPath, | ||||
| 		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) { | ||||
| 		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) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue