api-server/router/router.go

26 lines
432 B
Go
Raw Normal View History

2024-09-24 05:31:28 +00:00
package router
import (
"api/config"
"api/utils"
"log"
"net/http"
"time"
)
func InitGlobalVariable() {
// 初始化 Viper
utils.InitViper()
}
func Server() *http.Server {
serverPort := config.Cfg.Server.ServerPort
log.Printf("服务启动于 %s 端口", serverPort)
return &http.Server{
Addr: serverPort,
Handler: ServerRouter(),
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}
}