forked from inhere/go-web-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (40 loc) · 1.1 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
47
48
49
50
51
52
53
package main
import (
"fmt"
"os"
"github.com/inhere/go-web-skeleton/app/bootstrap"
"github.com/inhere/go-web-skeleton/app/clog"
"github.com/inhere/go-web-skeleton/web"
// boot and init some services(log, cache, eureka)
"github.com/inhere/go-web-skeleton/app"
// init redis, mongo, mysql connection
"github.com/gookit/rux"
"github.com/gookit/rux/handlers"
)
var router *rux.Router
func init() {
bootstrap.Web()
// router and routes
router = rux.New()
// global middleware
router.Use(handlers.RequestLogger())
web.AddRoutes(router)
}
// @title My Project API
// @version 1.0
// @description My Project API
// @termsOfService https://github.com/inhere
// @contact.name API Support
// @contact.url https://github.com/inhere
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @BasePath /v1
func main() {
clog.Printf(
"======================== Begin Running(PID: %d) ========================\n",
os.Getpid(),
)
// default is listen and serve on 0.0.0.0:8080
router.Listen(fmt.Sprintf("0.0.0.0:%d", app.HttpPort))
}