mirror of https://gitee.com/answerdev/answer.git
add install web api
This commit is contained in:
parent
79cc30355a
commit
b78f3061cb
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/answerdev/answer/internal/base/server"
|
||||||
"github.com/answerdev/answer/internal/cli"
|
"github.com/answerdev/answer/internal/cli"
|
||||||
"github.com/answerdev/answer/internal/migrations"
|
"github.com/answerdev/answer/internal/migrations"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -59,6 +60,8 @@ To run answer, use:
|
||||||
Short: "init answer application",
|
Short: "init answer application",
|
||||||
Long: `init answer application`,
|
Long: `init answer application`,
|
||||||
Run: func(_ *cobra.Command, _ []string) {
|
Run: func(_ *cobra.Command, _ []string) {
|
||||||
|
installwebapi := server.NewInstallHTTPServer()
|
||||||
|
installwebapi.Run(":8088")
|
||||||
cli.InstallAllInitialEnvironment(dataDirPath)
|
cli.InstallAllInitialEnvironment(dataDirPath)
|
||||||
c, err := readConfig()
|
c, err := readConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue