diff --git a/server/config/parser.go b/server/config/config.go similarity index 95% rename from server/config/parser.go rename to server/config/config.go index 72b2edc..fc15784 100644 --- a/server/config/parser.go +++ b/server/config/config.go @@ -10,6 +10,7 @@ import ( type Config struct { CurrentLogFile string LogPath string `yaml:"log_path"` + BaseURL string `yaml:"base_url"` Host string `yaml:"host"` Port int `yaml:"port"` DownloadPath string `yaml:"downloadPath"` diff --git a/server/server.go b/server/server.go index 06f8702..7b140a2 100644 --- a/server/server.go +++ b/server/server.go @@ -157,8 +157,11 @@ func newServer(c serverConfig) *http.Server { // use in dev // r.Use(middleware.Logger) - r.Mount("/", http.FileServer(http.FS(c.frontend))) - r.Mount("/openapi", http.FileServer(http.FS(c.swagger))) + baseUrl := config.Instance().BaseURL + r.Mount(baseUrl+"/", http.StripPrefix(baseUrl, http.FileServerFS(c.frontend))) + + // swagger + r.Mount("/openapi", http.FileServerFS(c.swagger)) // Archive routes r.Route("/archive", func(r chi.Router) { @@ -209,7 +212,7 @@ func gracefulShutdown(srv *http.Server, db *internal.MemoryDB) { defer func() { db.Persist() stop() - srv.Shutdown(context.TODO()) + srv.Shutdown(context.Background()) }() }() }