MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / NewHTTPServer

Function NewHTTPServer

internal/server/http.go:87–113  ·  view source on GitHub ↗

NewHTTPServer creates a new http server

(addr string, opts ...HTTPOption)

Source from the content-addressed store, hash-verified

85
86// NewHTTPServer creates a new http server
87func NewHTTPServer(addr string, opts ...HTTPOption) app.IServer {
88 o := defaultHTTPOptions()
89 o.apply(opts...)
90
91 if o.isProd {
92 gin.SetMode(gin.ReleaseMode)
93 } else {
94 gin.SetMode(gin.DebugMode)
95 }
96
97 router := routers.NewRouter()
98 server := &http.Server{
99 Addr: addr,
100 Handler: router,
101 //ReadTimeout: time.Second*30,
102 //WriteTimeout: time.Second*60,
103 IdleTimeout: time.Second * 60,
104 MaxHeaderBytes: 1 << 20,
105 }
106
107 return &httpServer{
108 addr: addr,
109 server: newServer(server, o.tls),
110 iRegistry: o.iRegistry,
111 instance: o.instance,
112 }
113}
114
115// delete the templates code start
116

Callers 4

CreateServicesFunction · 0.92
CreateServicesFunction · 0.92
CreateServicesFunction · 0.92
TestHTTPServerFunction · 0.85

Calls 4

NewRouterFunction · 0.92
defaultHTTPOptionsFunction · 0.85
newServerFunction · 0.85
applyMethod · 0.65

Tested by 1

TestHTTPServerFunction · 0.68