Documentation ¶
Index ¶
- Constants
- Variables
- func AsHandler(method string, path string, handler any, middlewares ...any) fx.Option
- func AsHandlersGroup(prefix string, handlersRegistrations []*HandlerRegistration, ...) fx.Option
- func AsMiddleware(middleware any, kind MiddlewareKind) fx.Option
- func CtxAuthenticationContext(c echo.Context) (*fxauthenticationcontext.AuthenticationContext, error)
- func CtxHttpClient(c echo.Context, opts ...fxhttpclient.HttpClientOption) *fxhttpclient.HttpClient
- func CtxLogger(c echo.Context) *fxlogger.Logger
- func CtxTracer(c echo.Context) trace.Tracer
- func NewFxHttpServer(p FxHttpServerParam) (*echo.Echo, error)
- func NewHttpServerErrorHandler(config *fxconfig.Config) echo.HTTPErrorHandler
- func RegisterHandler(handlerRegistration *HandlerRegistration) fx.Option
- func RegisterHandlersGroup(handlersGroupRegistration *HandlersGroupRegistration) fx.Option
- func RegisterMiddleware(middlewareRegistration *MiddlewareRegistration) fx.Option
- func StartFxHttpServer() fx.Option
- type DefaultHttpServerFactory
- type EchoLogger
- func (e *EchoLogger) Debug(i ...interface{})
- func (e *EchoLogger) Debugf(format string, args ...interface{})
- func (e *EchoLogger) Debugj(j log.JSON)
- func (e *EchoLogger) Error(i ...interface{})
- func (e *EchoLogger) Errorf(format string, args ...interface{})
- func (e *EchoLogger) Errorj(j log.JSON)
- func (e *EchoLogger) Fatal(i ...interface{})
- func (e *EchoLogger) Fatalf(format string, args ...interface{})
- func (e *EchoLogger) Fatalj(j log.JSON)
- func (e *EchoLogger) Info(i ...interface{})
- func (e *EchoLogger) Infof(format string, args ...interface{})
- func (e *EchoLogger) Infoj(j log.JSON)
- func (e *EchoLogger) Level() log.Lvl
- func (e *EchoLogger) Output() io.Writer
- func (e *EchoLogger) Panic(i ...interface{})
- func (e *EchoLogger) Panicf(format string, args ...interface{})
- func (e *EchoLogger) Panicj(j log.JSON)
- func (e *EchoLogger) Prefix() string
- func (e *EchoLogger) Print(i ...interface{})
- func (e *EchoLogger) Printf(format string, i ...interface{})
- func (e *EchoLogger) Printj(j log.JSON)
- func (e *EchoLogger) SetHeader(h string)
- func (e *EchoLogger) SetLevel(v log.Lvl)
- func (e *EchoLogger) SetLogger(logger *fxlogger.Logger) *EchoLogger
- func (e *EchoLogger) SetOutput(w io.Writer)
- func (e *EchoLogger) SetPrefix(p string)
- func (e *EchoLogger) ToZerolog() *zerolog.Logger
- func (e *EchoLogger) Warn(i ...interface{})
- func (e *EchoLogger) Warnf(format string, args ...interface{})
- func (e *EchoLogger) Warnj(j log.JSON)
- type FxHttpServerParam
- type FxHttpServerRegistryParam
- type Handler
- type HandlerDefinition
- type HandlerRegistration
- type HandlersGroupDefinition
- type HandlersGroupRegistration
- type HttpServerFactory
- type HttpServerOption
- func WithBanner(b bool) HttpServerOption
- func WithBinder(b echo.Binder) HttpServerOption
- func WithDebug(d bool) HttpServerOption
- func WithHttpErrorHandler(h echo.HTTPErrorHandler) HttpServerOption
- func WithJsonSerializer(s echo.JSONSerializer) HttpServerOption
- func WithLogger(l echo.Logger) HttpServerOption
- type HttpServerRegistry
- func (r *HttpServerRegistry) LookupRegisteredHandler(handler string) (Handler, error)
- func (r *HttpServerRegistry) LookupRegisteredMiddleware(middleware string) (Middleware, error)
- func (r *HttpServerRegistry) ResolveHandlers() ([]ResolvedHandler, error)
- func (r *HttpServerRegistry) ResolveHandlersGroups() ([]ResolvedHandlersGroup, error)
- func (r *HttpServerRegistry) ResolveMiddlewares() ([]ResolvedMiddleware, error)
- type Middleware
- type MiddlewareDefinition
- type MiddlewareKind
- type MiddlewareRegistration
- type ResolvedHandler
- type ResolvedHandlersGroup
- type ResolvedMiddleware
Constants ¶
View Source
const ( DefaultPort = 8080 HeaderXRequestId = "x-request-id" HeaderTraceParent = "traceparent" )
Variables ¶
View Source
var FxHttpServerModule = fx.Module( "http-server", fx.Provide( NewDefaultHttpServerFactory, NewFxHttpServerRegistry, NewFxHttpServer, ), )
Functions ¶
func AsHandlersGroup ¶
func AsHandlersGroup(prefix string, handlersRegistrations []*HandlerRegistration, middlewares ...any) fx.Option
func AsMiddleware ¶
func AsMiddleware(middleware any, kind MiddlewareKind) fx.Option
func CtxAuthenticationContext ¶
func CtxAuthenticationContext(c echo.Context) (*fxauthenticationcontext.AuthenticationContext, error)
func CtxHttpClient ¶
func CtxHttpClient(c echo.Context, opts ...fxhttpclient.HttpClientOption) *fxhttpclient.HttpClient
func NewFxHttpServer ¶
func NewFxHttpServer(p FxHttpServerParam) (*echo.Echo, error)
func RegisterHandler ¶
func RegisterHandler(handlerRegistration *HandlerRegistration) fx.Option
func RegisterHandlersGroup ¶
func RegisterHandlersGroup(handlersGroupRegistration *HandlersGroupRegistration) fx.Option
func RegisterMiddleware ¶
func RegisterMiddleware(middlewareRegistration *MiddlewareRegistration) fx.Option
func StartFxHttpServer ¶
Types ¶
type DefaultHttpServerFactory ¶
type DefaultHttpServerFactory struct{}
func (*DefaultHttpServerFactory) Create ¶
func (f *DefaultHttpServerFactory) Create(options ...HttpServerOption) (*echo.Echo, error)
type EchoLogger ¶
type EchoLogger struct {
// contains filtered or unexported fields
}
func NewEchoLogger ¶
func NewEchoLogger(logger *fxlogger.Logger) *EchoLogger
func (*EchoLogger) Debug ¶
func (e *EchoLogger) Debug(i ...interface{})
func (*EchoLogger) Debugf ¶
func (e *EchoLogger) Debugf(format string, args ...interface{})
func (*EchoLogger) Debugj ¶
func (e *EchoLogger) Debugj(j log.JSON)
func (*EchoLogger) Error ¶
func (e *EchoLogger) Error(i ...interface{})
func (*EchoLogger) Errorf ¶
func (e *EchoLogger) Errorf(format string, args ...interface{})
func (*EchoLogger) Errorj ¶
func (e *EchoLogger) Errorj(j log.JSON)
func (*EchoLogger) Fatal ¶
func (e *EchoLogger) Fatal(i ...interface{})
func (*EchoLogger) Fatalf ¶
func (e *EchoLogger) Fatalf(format string, args ...interface{})
func (*EchoLogger) Fatalj ¶
func (e *EchoLogger) Fatalj(j log.JSON)
func (*EchoLogger) Info ¶
func (e *EchoLogger) Info(i ...interface{})
func (*EchoLogger) Infof ¶
func (e *EchoLogger) Infof(format string, args ...interface{})
func (*EchoLogger) Infoj ¶
func (e *EchoLogger) Infoj(j log.JSON)
func (*EchoLogger) Level ¶
func (e *EchoLogger) Level() log.Lvl
func (*EchoLogger) Output ¶
func (e *EchoLogger) Output() io.Writer
func (*EchoLogger) Panic ¶
func (e *EchoLogger) Panic(i ...interface{})
func (*EchoLogger) Panicf ¶
func (e *EchoLogger) Panicf(format string, args ...interface{})
func (*EchoLogger) Panicj ¶
func (e *EchoLogger) Panicj(j log.JSON)
func (*EchoLogger) Prefix ¶
func (e *EchoLogger) Prefix() string
func (*EchoLogger) Print ¶
func (e *EchoLogger) Print(i ...interface{})
func (*EchoLogger) Printf ¶
func (e *EchoLogger) Printf(format string, i ...interface{})
func (*EchoLogger) Printj ¶
func (e *EchoLogger) Printj(j log.JSON)
func (*EchoLogger) SetHeader ¶
func (e *EchoLogger) SetHeader(h string)
func (*EchoLogger) SetLevel ¶
func (e *EchoLogger) SetLevel(v log.Lvl)
func (*EchoLogger) SetLogger ¶
func (e *EchoLogger) SetLogger(logger *fxlogger.Logger) *EchoLogger
func (*EchoLogger) SetOutput ¶
func (e *EchoLogger) SetOutput(w io.Writer)
func (*EchoLogger) SetPrefix ¶
func (e *EchoLogger) SetPrefix(p string)
func (*EchoLogger) ToZerolog ¶
func (e *EchoLogger) ToZerolog() *zerolog.Logger
func (*EchoLogger) Warn ¶
func (e *EchoLogger) Warn(i ...interface{})
func (*EchoLogger) Warnf ¶
func (e *EchoLogger) Warnf(format string, args ...interface{})
func (*EchoLogger) Warnj ¶
func (e *EchoLogger) Warnj(j log.JSON)
type FxHttpServerParam ¶
type FxHttpServerParam struct { fx.In LifeCycle fx.Lifecycle Factory HttpServerFactory Registry *HttpServerRegistry Config *fxconfig.Config Logger *fxlogger.Logger TracerProvider *trace.TracerProvider HealthChecker *fxhealthchecker.HealthChecker }
type FxHttpServerRegistryParam ¶
type FxHttpServerRegistryParam struct { fx.In Middlewares []Middleware `group:"http-server-middlewares"` MiddlewareDefinitions []MiddlewareDefinition `group:"http-server-middleware-definitions"` Handlers []Handler `group:"http-server-handlers"` HandlerDefinitions []HandlerDefinition `group:"http-server-handler-definitions"` HandlersGroupDefinitions []HandlersGroupDefinition `group:"http-server-handlers-group-definitions"` }
type HandlerDefinition ¶
type HandlerDefinition interface { Concrete() bool Method() string Path() string Handler() any Middlewares() []MiddlewareDefinition }
type HandlerRegistration ¶
type HandlerRegistration struct {
// contains filtered or unexported fields
}
func NewHandlerRegistration ¶
func NewHandlerRegistration(method string, path string, handler any, middlewares ...any) *HandlerRegistration
func (*HandlerRegistration) Handler ¶
func (h *HandlerRegistration) Handler() any
func (*HandlerRegistration) Method ¶
func (h *HandlerRegistration) Method() string
func (*HandlerRegistration) Middlewares ¶
func (h *HandlerRegistration) Middlewares() []any
func (*HandlerRegistration) Path ¶
func (h *HandlerRegistration) Path() string
type HandlersGroupDefinition ¶
type HandlersGroupDefinition interface { Prefix() string Handlers() []HandlerDefinition Middlewares() []MiddlewareDefinition }
type HandlersGroupRegistration ¶
type HandlersGroupRegistration struct {
// contains filtered or unexported fields
}
func NewHandlersGroupRegistration ¶
func NewHandlersGroupRegistration(prefix string, handlersRegistrations []*HandlerRegistration, middlewares ...any) *HandlersGroupRegistration
func (*HandlersGroupRegistration) HandlersRegistrations ¶
func (h *HandlersGroupRegistration) HandlersRegistrations() []*HandlerRegistration
func (*HandlersGroupRegistration) Middlewares ¶
func (h *HandlersGroupRegistration) Middlewares() []any
func (*HandlersGroupRegistration) Prefix ¶
func (h *HandlersGroupRegistration) Prefix() string
type HttpServerFactory ¶
type HttpServerFactory interface {
Create(options ...HttpServerOption) (*echo.Echo, error)
}
func NewDefaultHttpServerFactory ¶
func NewDefaultHttpServerFactory() HttpServerFactory
type HttpServerOption ¶
type HttpServerOption func(o *options)
func WithBanner ¶
func WithBanner(b bool) HttpServerOption
func WithBinder ¶
func WithBinder(b echo.Binder) HttpServerOption
func WithDebug ¶
func WithDebug(d bool) HttpServerOption
func WithHttpErrorHandler ¶
func WithHttpErrorHandler(h echo.HTTPErrorHandler) HttpServerOption
func WithJsonSerializer ¶
func WithJsonSerializer(s echo.JSONSerializer) HttpServerOption
func WithLogger ¶
func WithLogger(l echo.Logger) HttpServerOption
type HttpServerRegistry ¶
type HttpServerRegistry struct {
// contains filtered or unexported fields
}
func NewFxHttpServerRegistry ¶
func NewFxHttpServerRegistry(p FxHttpServerRegistryParam) *HttpServerRegistry
func (*HttpServerRegistry) LookupRegisteredHandler ¶
func (r *HttpServerRegistry) LookupRegisteredHandler(handler string) (Handler, error)
func (*HttpServerRegistry) LookupRegisteredMiddleware ¶
func (r *HttpServerRegistry) LookupRegisteredMiddleware(middleware string) (Middleware, error)
func (*HttpServerRegistry) ResolveHandlers ¶
func (r *HttpServerRegistry) ResolveHandlers() ([]ResolvedHandler, error)
func (*HttpServerRegistry) ResolveHandlersGroups ¶
func (r *HttpServerRegistry) ResolveHandlersGroups() ([]ResolvedHandlersGroup, error)
func (*HttpServerRegistry) ResolveMiddlewares ¶
func (r *HttpServerRegistry) ResolveMiddlewares() ([]ResolvedMiddleware, error)
type Middleware ¶
type Middleware interface {
Handle() echo.MiddlewareFunc
}
type MiddlewareDefinition ¶
type MiddlewareDefinition interface { Concrete() bool Middleware() any Kind() MiddlewareKind }
type MiddlewareKind ¶
type MiddlewareKind int
const ( GlobalUse MiddlewareKind = iota GlobalPre Attached )
func (MiddlewareKind) String ¶
func (k MiddlewareKind) String() string
type MiddlewareRegistration ¶
type MiddlewareRegistration struct {
// contains filtered or unexported fields
}
func NewMiddlewareRegistration ¶
func NewMiddlewareRegistration(middleware any, kind MiddlewareKind) *MiddlewareRegistration
func (*MiddlewareRegistration) Kind ¶
func (m *MiddlewareRegistration) Kind() MiddlewareKind
func (*MiddlewareRegistration) Middleware ¶
func (m *MiddlewareRegistration) Middleware() any
type ResolvedHandler ¶
type ResolvedHandlersGroup ¶
type ResolvedHandlersGroup interface { Prefix() string Handlers() []ResolvedHandler Middlewares() []echo.MiddlewareFunc }
type ResolvedMiddleware ¶
type ResolvedMiddleware interface { Middleware() echo.MiddlewareFunc Kind() MiddlewareKind }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.