test_data/initialization/run.server.go
2024-07-17 15:13:00 +08:00

24 lines
421 B
Go

package initialization
import (
"github.com/spf13/viper"
"net/http"
"time"
)
func RunServer() {
port := viper.GetString("system.port")
r := InitRouter()
s := &http.Server{
Addr: port,
Handler: r,
ReadTimeout: 120 * time.Second,
WriteTimeout: 120 * time.Second,
MaxHeaderBytes: 1 << 20,
}
println("run on port", port)
if err := s.ListenAndServe(); err != nil {
panic(err)
}
}