prepare for test deployment
embed static files remove hard tls requirement
This commit is contained in:
		
							parent
							
								
									64ff095002
								
							
						
					
					
						commit
						1b44d23dd6
					
				| @ -78,7 +78,11 @@ func main() { | |||||||
| 
 | 
 | ||||||
| 	logger.Info("Starting server", slog.Any("addr", *addr)) | 	logger.Info("Starting server", slog.Any("addr", *addr)) | ||||||
| 
 | 
 | ||||||
|  | 	if app.debug { | ||||||
| 		err = srv.ListenAndServeTLS("./tls/cert.pem", "./tls/key.pem") | 		err = srv.ListenAndServeTLS("./tls/cert.pem", "./tls/key.pem") | ||||||
|  | 	} else { | ||||||
|  | 		err = srv.ListenAndServe() | ||||||
|  | 	} | ||||||
| 	logger.Error(err.Error()) | 	logger.Error(err.Error()) | ||||||
| 	os.Exit(1) | 	os.Exit(1) | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,13 +3,13 @@ package main | |||||||
| import ( | import ( | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 
 | 
 | ||||||
|  | 	"git.32bit.cafe/32bitcafe/guestbook/ui" | ||||||
| 	"github.com/justinas/alice" | 	"github.com/justinas/alice" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (app *application) routes() http.Handler { | func (app *application) routes() http.Handler { | ||||||
| 	mux := http.NewServeMux() | 	mux := http.NewServeMux() | ||||||
| 	fileServer := http.FileServer(http.Dir("./ui/static")) | 	mux.Handle("GET /static/", http.FileServerFS(ui.Files)) | ||||||
| 	mux.Handle("GET /static/", http.StripPrefix("/static", fileServer)) |  | ||||||
| 
 | 
 | ||||||
| 	dynamic := alice.New(app.sessionManager.LoadAndSave, noSurf, app.authenticate) | 	dynamic := alice.New(app.sessionManager.LoadAndSave, noSurf, app.authenticate) | ||||||
| 	standard := alice.New(app.recoverPanic, app.logRequest, commonHeaders) | 	standard := alice.New(app.recoverPanic, app.logRequest, commonHeaders) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user