From d6cf67b3d7747b6274d92e394d75d348060fa5f5 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Sun, 25 Jun 2023 16:03:36 +0200 Subject: feat: Add static file to output bin Now the final binary has a standalone web server including necessary static file. --- cmd/server/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmd/server') diff --git a/cmd/server/main.go b/cmd/server/main.go index 0fa5fea..4ca39de 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -16,6 +16,7 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" + "git.sr.ht/~gabrielgio/img" "git.sr.ht/~gabrielgio/img/pkg/components/auth" "git.sr.ht/~gabrielgio/img/pkg/components/filesystem" "git.sr.ht/~gabrielgio/img/pkg/components/media" @@ -69,8 +70,7 @@ func main() { } r := router.New() - r.ServeFiles("/static/{filepath:*}", "./static") - r.NotFound = ext.NotFoundHTML + r.GET("/static/{filepath:*}", ext.FileServer(img.StaticFS, "static/")) authMiddleware := ext.NewAuthMiddleware(hexKey, logger.WithField("context", "auth")) logMiddleware := ext.NewLogMiddleare(logger.WithField("context", "http")) -- cgit v1.2.3