This commit is contained in:
ideaa
2025-05-23 18:22:27 +08:00
parent eb04ace652
commit 57cb28f47e
19 changed files with 538 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
package cmd
import (
"github.com/gin-gonic/gin"
"github.com/spf13/cobra"
"github.com/wonli/aqi"
"{{.PackageName}}/internal/dbc"
"{{.PackageName}}/internal/router"
)
func init() {
rootCmd.AddCommand(api)
}
var api = &cobra.Command{
Use: "api",
Short: "启动API",
Run: func(cmd *cobra.Command, args []string) {
app := aqi.Init(
aqi.ConfigFile(configFile),
aqi.HttpServer("Api", "apiPort"),
)
dbc.InitDBC()
g := gin.Default()
go router.Api(g)
go router.Actions(app)
app.WithHttpServer(g)
app.Start()
},
}