From 769ce2389704ee734f3edc4483cc8efa585917cd Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 30 Jan 2024 18:55:55 +0800 Subject: [PATCH] :sparkles: Serve frontend with embed --- pkg/server/startup.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/server/startup.go b/pkg/server/startup.go index 6c61f3e..779cef7 100644 --- a/pkg/server/startup.go +++ b/pkg/server/startup.go @@ -1,10 +1,13 @@ package server import ( + "code.smartsheep.studio/hydrogen/passport/pkg/view" "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/filesystem" jsoniter "github.com/json-iterator/go" "github.com/rs/zerolog/log" "github.com/spf13/viper" + "net/http" ) var A *fiber.App @@ -17,8 +20,16 @@ func NewServer() { AppName: "Hydrogen.Passport", JSONEncoder: jsoniter.ConfigCompatibleWithStandardLibrary.Marshal, JSONDecoder: jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal, + EnablePrintRoutes: viper.GetBool("debug"), }) + A.Use("/", filesystem.New(filesystem.Config{ + Root: http.FS(view.FS), + PathPrefix: "dist", + Index: "index.html", + NotFoundFile: "index.html", + })) + A.Get("/.well-known", getMetadata) A.Get("/.well-known/openid-configuration", getOidcConfiguration)