defines the method to customize http server (#2171)
This commit is contained in:
@@ -301,21 +301,25 @@ func (ng *engine) signatureVerifier(signature signatureSetting) (func(chain.Chai
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ng *engine) start(router httpx.Router) error {
|
||||
func (ng *engine) start(router httpx.Router, opts ...internal.StartOption) error {
|
||||
if err := ng.bindRoutes(router); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
opts = append(opts, ng.withTimeout())
|
||||
|
||||
if len(ng.conf.CertFile) == 0 && len(ng.conf.KeyFile) == 0 {
|
||||
return internal.StartHttp(ng.conf.Host, ng.conf.Port, router, ng.withTimeout())
|
||||
return internal.StartHttp(ng.conf.Host, ng.conf.Port, router, opts...)
|
||||
}
|
||||
|
||||
opts = append(opts, func(svr *http.Server) {
|
||||
if ng.tlsConfig != nil {
|
||||
svr.TLSConfig = ng.tlsConfig
|
||||
}
|
||||
})
|
||||
|
||||
return internal.StartHttps(ng.conf.Host, ng.conf.Port, ng.conf.CertFile,
|
||||
ng.conf.KeyFile, router, func(svr *http.Server) {
|
||||
if ng.tlsConfig != nil {
|
||||
svr.TLSConfig = ng.tlsConfig
|
||||
}
|
||||
}, ng.withTimeout())
|
||||
ng.conf.KeyFile, router, opts...)
|
||||
}
|
||||
|
||||
func (ng *engine) use(middleware Middleware) {
|
||||
|
||||
Reference in New Issue
Block a user