feat: configure application transports and unify graceful shutdown

This commit is contained in:
2026-09-23 12:49:56 +08:00
parent 59bf04a461
commit 8e18528fc2
18 changed files with 842 additions and 96 deletions

11
omni.go
View File

@@ -25,12 +25,19 @@ type Router = httpx.Router
type HTTPRouterGroup = httpx.RouterGroup
type APIError = apierrors.APIError
type Config = config.Config
type TLSConfig = config.TLSConfig
type Option = config.Option
type Response = response.Response
type LogConfig = logx.Config
type Logger = logx.Logger
type Metrics = metrics.Metrics
const (
TransportNetHTTP = config.TransportNetHTTP
TransportNative = config.TransportNative
TransportHTTP2 = config.TransportHTTP2
)
func New(options ...Option) *App { return app.New(options...) }
func NewWithRouter(router Router, options ...Option) *App {
@@ -45,6 +52,10 @@ func WithTrustedProxies(proxies ...string) Option { return config.WithTrustedPro
func WithConfig(settings Config) Option { return config.WithConfig(settings) }
func WithTransport(name string) Option { return config.WithTransport(name) }
func WithTLS(certFile, keyFile string) Option { return config.WithTLS(certFile, keyFile) }
func WithLogConfig(settings LogConfig) Option { return config.WithLogConfig(settings) }
func WithShutdownTimeout(timeout time.Duration) Option { return config.WithShutdownTimeout(timeout) }