add install web api

This commit is contained in:
aichy126 2022-11-02 17:09:16 +08:00
parent 79cc30355a
commit b78f3061cb
2 changed files with 29 additions and 0 deletions

View File

@ -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 {

View File

@ -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
}