forked from togettoyou/ipashare
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
executable file
·56 lines (50 loc) · 1.41 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
54
55
56
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"log"
"net/http"
"super-signature/cron"
_ "super-signature/docs"
"super-signature/models"
"super-signature/pkg/setting"
"super-signature/routers"
"time"
)
func init() {
setting.Setup()
models.Setup()
go cron.Init()
}
// @title iOS超级签名
// @version 1.0
// @description iOS超级签名API接口文档
func main() {
gin.SetMode(setting.ServerSetting.RunMode)
routersInit := routers.InitRouter()
readTimeout := setting.ServerSetting.ReadTimeout
writeTimeout := setting.ServerSetting.WriteTimeout
endPoint := fmt.Sprintf(":%d", setting.ServerSetting.HttpPort)
maxHeaderBytes := 1 << 20
server := &http.Server{
Addr: endPoint,
Handler: routersInit,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
MaxHeaderBytes: maxHeaderBytes,
}
log.Printf("[info] Set Time Zone to Asia/Chongqing")
timeLocal, err := time.LoadLocation("Asia/Chongqing")
if err != nil {
log.Printf("[error] Set Time Zone to Asia/Chongqing failed %s", err)
}
time.Local = timeLocal
log.Printf("[info] start https server listening %s", endPoint)
//启用https,需要将ssl.pem和ssl.key放置项目目录下
if err := server.ListenAndServeTLS("./ssl.pem", "./ssl.key"); err != nil {
log.Printf("start https server failed %s", err)
}
//if err := server.ListenAndServe(); err != nil {
// log.Printf("start http server failed %s", err)
//}
}