-
Notifications
You must be signed in to change notification settings - Fork 27
/
main.go
46 lines (41 loc) · 1.44 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"context"
"flag"
"fmt"
"github.com/go-nunu/nunu-layout-advanced/cmd/server/wire"
"github.com/go-nunu/nunu-layout-advanced/pkg/config"
"github.com/go-nunu/nunu-layout-advanced/pkg/log"
"go.uber.org/zap"
)
// @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)
}
}