You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.1 KiB
Go

// api
//
// Description: api service
//
// Schemes: http, https
// Host: localhost:0
// BasePath: /
// Version: 0.0.1
// SecurityDefinitions:
// Token:
// type: apiKey
// name: Authorization
// in: header
// Security:
// - Token: []
// Consumes:
// - application/json
//
// Produces:
// - application/json
//
// swagger:meta
package main
import (
"flag"
"fmt"
"git.noahlan.cn/noahlan/ntool-biz/core/i18n"
"git.noahlan.cn/n-admin/n-admin-server/api/internal/config"
"git.noahlan.cn/n-admin/n-admin-server/api/internal/handler"
"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "api/etc/api-dev.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c, conf.UseEnv())
server := rest.MustNewServer(c.RestConf, rest.WithCors(c.CORSConf.Address))
defer server.Stop()
// i18n
server.Use(i18n.WithI18nMiddleware())
ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}