Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

update install api

aichy126784f9631f7df
diff --git a/internal/base/server/install.go b/internal/base/server/install.go
index d4b44d90..f2d28bbe 100644
--- a/internal/base/server/install.go
+++ b/internal/base/server/install.go
@@ -2,16 +2,28 @@ package server
import (
"embed"
+ "fmt"
+ "io/fs"
"net/http"
"github.com/answerdev/answer/ui"
"github.com/gin-gonic/gin"
+ "github.com/segmentfault/pacman/log"
)
+const UIStaticPath = "build/static"
+
type _resource struct {
fs embed.FS
}
+// Open to implement the interface by http.FS required
+func (r *_resource) Open(name string) (fs.File, error) {
+ name = fmt.Sprintf(UIStaticPath+"/%s", name)
+ log.Debugf("open static path %s", name)
+ return r.fs.Open(name)
+}
+
// NewHTTPServer new http server.
func NewInstallHTTPServer() *gin.Engine {
r := gin.New()
@@ -20,7 +32,10 @@ func NewInstallHTTPServer() *gin.Engine {
r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK??") })
// gin.SetMode(gin.ReleaseMode)
- r.StaticFS("/static", http.FS(ui.Build))
+
+ r.StaticFS("/static", http.FS(&_resource{
+ fs: ui.Build,
+ }))
return r
}