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.

add install web api

aichy126b78f3061cb29
diff --git a/cmd/answer/command.go b/cmd/answer/command.go
index d0efb0ab..27655443 100644
--- a/cmd/answer/command.go
+++ b/cmd/answer/command.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
+ "github.com/answerdev/answer/internal/base/server"
"github.com/answerdev/answer/internal/cli"
"github.com/answerdev/answer/internal/migrations"
"github.com/spf13/cobra"
@@ -59,6 +60,8 @@ To run answer, use:
Short: "init answer application",
Long: `init answer application`,
Run: func(_ *cobra.Command, _ []string) {
+ installwebapi := server.NewInstallHTTPServer()
+ installwebapi.Run(":8088")
cli.InstallAllInitialEnvironment(dataDirPath)
c, err := readConfig()
if err != nil {
diff --git a/internal/base/server/install.go b/internal/base/server/install.go
new file mode 100644
index 00000000..d4b44d90
--- /dev/null
+++ b/internal/base/server/install.go
@@ -0,0 +1,26 @@
+package server
+
+import (
+ "embed"
+ "net/http"
+
+ "github.com/answerdev/answer/ui"
+ "github.com/gin-gonic/gin"
+)
+
+type _resource struct {
+ fs embed.FS
+}
+
+// NewHTTPServer new http server.
+func NewInstallHTTPServer() *gin.Engine {
+ r := gin.New()
+ gin.SetMode(gin.DebugMode)
+
+ r.GET("/healthz", func(ctx *gin.Context) { ctx.String(200, "OK??") })
+
+ // gin.SetMode(gin.ReleaseMode)
+ r.StaticFS("/static", http.FS(ui.Build))
+
+ return r
+}