Documentation ¶
Index ¶
- func RecoveryMiddleware(handler http.Handler) http.Handler
- func RequestLoggerMiddleware(handler http.Handler) http.Handler
- type CORSOptions
- type DependencyProvider
- type Middleware
- type ServerOption
- func WithCORS(opts CORSOptions) ServerOption
- func WithRecoveryMiddleware(middleware Middleware) ServerOption
- func WithRequestLoggerMiddleware(middleware Middleware) ServerOption
- func WithTracePropagator(propagator propagation.TextMapPropagator) ServerOption
- func WithTracing(traceName string, tp trace.TracerProvider) ServerOption
- type WebServer
- func (w *WebServer) AddDependency(provider DependencyProvider, objProto any)
- func (w *WebServer) AddMiddlewares(middlewares ...Middleware)
- func (w *WebServer) AddToContext(key string, value any)
- func (w *WebServer) Route(endpoint string, route any, methods ...string)
- func (w *WebServer) Run(addr string) error
- func (w *WebServer) ServeHTTP(writer http.ResponseWriter, r *http.Request)
- func (w *WebServer) Shutdown(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CORSOptions ¶
type DependencyProvider ¶
type DependencyProvider func(ctx *webcontext.Context) any
type Middleware ¶
type Middleware mux.MiddlewareFunc
type ServerOption ¶
func WithCORS ¶
func WithCORS(opts CORSOptions) ServerOption
func WithRecoveryMiddleware ¶
func WithRecoveryMiddleware(middleware Middleware) ServerOption
func WithRequestLoggerMiddleware ¶
func WithRequestLoggerMiddleware(middleware Middleware) ServerOption
func WithTracePropagator ¶ added in v0.0.2
func WithTracePropagator(propagator propagation.TextMapPropagator) ServerOption
WithTracePropagator replaces the default propagator with the one provided
func WithTracing ¶ added in v0.0.2
func WithTracing(traceName string, tp trace.TracerProvider) ServerOption
WithTracing option adds an OpenTelemetry's tracing SDK implementation to the server
type WebServer ¶
type WebServer struct {
// contains filtered or unexported fields
}
func NewWebServer ¶
func NewWebServer(options ...ServerOption) (*WebServer, error)
func (*WebServer) AddDependency ¶
func (w *WebServer) AddDependency(provider DependencyProvider, objProto any)
func (*WebServer) AddMiddlewares ¶
func (w *WebServer) AddMiddlewares(middlewares ...Middleware)
AddMiddlewares adds layers of handler functions to an existing route. Note that the ordering matters here, so the first argument is going to be called first Important Note: NewRequestLoggerMiddleware and NewRecoveryMiddleware are set separatedly, and always at start.
func (*WebServer) AddToContext ¶
Click to show internal directories.
Click to hide internal directories.