mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
feat: redesign server startup around Run options
Replace the old RunShutdown and RunTLS style entry points with a single Run(opts...) API for v1. Add focused startup semantics tests, keep TLS and graceful shutdown independent, ensure sibling servers are cleaned up on startup failure, and update docs to match the new option-based startup model.
This commit is contained in:
parent
fca9bbd3ef
commit
e4d3eed379
13 changed files with 577 additions and 335 deletions
22
engine.go
22
engine.go
|
|
@ -404,11 +404,18 @@ func (engine *Engine) setProtocols(config *ProtocolsConfig) {
|
|||
}()
|
||||
}
|
||||
|
||||
// applyDefaultServerConfig 应用框架的默认配置到 http.Server
|
||||
func (engine *Engine) applyDefaultServerConfig(srv *http.Server) {
|
||||
if engine.serverProtocols != nil {
|
||||
srv.Protocols = engine.serverProtocols
|
||||
if engine.serverProtocols.HTTP2() || engine.serverProtocols.UnencryptedHTTP2() {
|
||||
func cloneServerProtocols(protocols *http.Protocols) *http.Protocols {
|
||||
if protocols == nil {
|
||||
return nil
|
||||
}
|
||||
cloned := *protocols
|
||||
return &cloned
|
||||
}
|
||||
|
||||
func applyServerProtocols(srv *http.Server, protocols *http.Protocols) {
|
||||
if protocols != nil {
|
||||
srv.Protocols = cloneServerProtocols(protocols)
|
||||
if srv.Protocols.HTTP2() || srv.Protocols.UnencryptedHTTP2() {
|
||||
if err := configureHTTP2ExtendedConnectServer(srv); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -416,6 +423,11 @@ func (engine *Engine) applyDefaultServerConfig(srv *http.Server) {
|
|||
}
|
||||
}
|
||||
|
||||
// applyDefaultServerConfig 应用框架的默认配置到 http.Server
|
||||
func (engine *Engine) applyDefaultServerConfig(srv *http.Server) {
|
||||
applyServerProtocols(srv, engine.serverProtocols)
|
||||
}
|
||||
|
||||
// 配置全局Req Body大小限制
|
||||
func (engine *Engine) SetGlobalMaxRequestBodySize(size int64) {
|
||||
engine.GlobalMaxRequestBodySize = size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue