api-server/router/router.go
2024-09-24 13:31:28 +08:00

26 lines
432 B
Go

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,
}
}