Serve frontend with embed
All checks were successful
release-nightly / build-docker (push) Successful in 3m2s

This commit is contained in:
LittleSheep 2024-01-30 18:55:55 +08:00
parent 6d056b6e1d
commit 769ce23897

View File

@ -1,10 +1,13 @@
package server package server
import ( import (
"code.smartsheep.studio/hydrogen/passport/pkg/view"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/filesystem"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/viper" "github.com/spf13/viper"
"net/http"
) )
var A *fiber.App var A *fiber.App
@ -17,8 +20,16 @@ func NewServer() {
AppName: "Hydrogen.Passport", AppName: "Hydrogen.Passport",
JSONEncoder: jsoniter.ConfigCompatibleWithStandardLibrary.Marshal, JSONEncoder: jsoniter.ConfigCompatibleWithStandardLibrary.Marshal,
JSONDecoder: jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal, 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", getMetadata)
A.Get("/.well-known/openid-configuration", getOidcConfiguration) A.Get("/.well-known/openid-configuration", getOidcConfiguration)