-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (31 loc) · 733 Bytes
/
Copy pathmain.go
File metadata and controls
38 lines (31 loc) · 733 Bytes
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
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/lzpsqzr/gin-api-example/pkg/setting"
"github.com/lzpsqzr/gin-api-example/routers"
"log"
"net/http"
)
var DB = make(map[string]string)
type error interface {
Error() string
}
func main() {
if setting.RunMode == "debug" {
gin.SetMode(gin.DebugMode)
} else if setting.RunMode == "release" {
gin.SetMode(gin.ReleaseMode)
} else {
log.Fatalf("Wrong run mode configured in config file ! ")
}
r := routers.Initrouters()
s := &http.Server{
Addr: fmt.Sprintf(":%d", setting.HTTPPort),
Handler: r,
ReadTimeout: setting.ReadTimeout,
WriteTimeout: setting.WriteTimeout,
MaxHeaderBytes: 1 << 20,
}
s.ListenAndServe()
}