47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"flag"
|
||
|
|
"fmt"
|
||
|
|
"nunu-layout-admin/pkg/log"
|
||
|
|
|
||
|
|
"go.uber.org/zap"
|
||
|
|
"nunu-layout-admin/cmd/server/wire"
|
||
|
|
"nunu-layout-admin/pkg/config"
|
||
|
|
)
|
||
|
|
|
||
|
|
// @title Nunu Example API
|
||
|
|
// @version 1.0.0
|
||
|
|
// @description This is a sample server celler server.
|
||
|
|
// @termsOfService http://swagger.io/terms/
|
||
|
|
// @contact.name API Support
|
||
|
|
// @contact.url http://www.swagger.io/support
|
||
|
|
// @contact.email support@swagger.io
|
||
|
|
// @license.name Apache 2.0
|
||
|
|
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||
|
|
// @host localhost:8000
|
||
|
|
// @securityDefinitions.apiKey Bearer
|
||
|
|
// @in header
|
||
|
|
// @name Authorization
|
||
|
|
// @externalDocs.description OpenAPI
|
||
|
|
// @externalDocs.url https://swagger.io/resources/open-api/
|
||
|
|
func main() {
|
||
|
|
var envConf = flag.String("conf", "config/local.yml", "config path, eg: -conf ./config/local.yml")
|
||
|
|
flag.Parse()
|
||
|
|
conf := config.NewConfig(*envConf)
|
||
|
|
|
||
|
|
logger := log.NewLog(conf)
|
||
|
|
|
||
|
|
app, cleanup, err := wire.NewWire(conf, logger)
|
||
|
|
defer cleanup()
|
||
|
|
if err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
logger.Info("server start", zap.String("host", fmt.Sprintf("http://%s:%d", conf.GetString("http.host"), conf.GetInt("http.port"))))
|
||
|
|
logger.Info("docs addr", zap.String("addr", fmt.Sprintf("http://%s:%d/swagger/index.html", conf.GetString("http.host"), conf.GetInt("http.port"))))
|
||
|
|
if err = app.Run(context.Background()); err != nil {
|
||
|
|
panic(err)
|
||
|
|
}
|
||
|
|
}
|