🐛 fix 404 on first hit

On first hit, Server() calls for the first time router(). As a result / and /static are only configured after first hit
This commit is contained in:
Ada 2024-02-16 22:41:29 +01:00
parent d5fea70587
commit 9360556006
Signed by: ada
GPG key ID: 6A7F898157C6DE6E

View file

@ -17,7 +17,7 @@ type ServerConfig struct {
}
// Configure HTTP router
func (config ServerConfig) router(_ http.ResponseWriter, _ *http.Request) {
func (config ServerConfig) router() {
WebConfig := plak.WebConfig{
DB: config.DB,
UrlLength: config.UrlLength,
@ -45,7 +45,7 @@ func Config(listenAddress string) *http.Server {
func (config ServerConfig) Server() {
log.Println("Listening on " + config.HTTPServer.Addr)
http.HandleFunc("/", config.router)
config.router()
log.Fatal(config.HTTPServer.ListenAndServe())
}