Documentation
¶
Index ¶
- type Config
- type Context
- type ContextKey
- type Handler
- type HandlerChain
- type HttpService
- type Metrics
- type MetricsProvider
- type Middleware
- type Result
- type Results
- func (r *Results) Abort() Result
- func (r *Results) BadRequest() Result
- func (r *Results) Bytes(body []byte) Result
- func (r *Results) Error(statusCode int, message []byte) Result
- func (r *Results) Json(body any) Result
- func (r *Results) NotFound() Result
- func (r *Results) Ok() Result
- func (r *Results) PlainText(body []byte) Result
- func (r *Results) Redirect(uri string) Result
- func (r *Results) Unauthorized(body []byte) Result
- type Route
- func (r *Route) HasDescription(description string) *Route
- func (r *Route) HasOperationId(operationId string) *Route
- func (r *Route) HasPathParameter(name string, description string) *Route
- func (r *Route) HasQueryParameter(name string, description string) *Route
- func (r *Route) HasRequestModel(model any) *Route
- func (r *Route) HasResponse(statusCode int) *Route
- func (r *Route) HasResponseModel(statusCode int, model any) *Route
- func (r *Route) HasSummary(summary string) *Route
- func (r *Route) HasTags(tags ...string) *Route
- func (r *Route) IsDeprecated() *Route
- type RouteOpenApiSpec
- type RouteOpenApiSpecRequest
- type RouteOpenApiSpecResponse
- type Router
- func (r *Router) GetHandlers() []Handler
- func (r *Router) GetMux() *http.ServeMux
- func (r *Router) GetPath() string
- func (r *Router) GetRoutes() []*Route
- func (r *Router) Group(path string) *Router
- func (r *Router) Route(pattern string, handlers ...Handler) *Route
- func (r *Router) Use(handlers ...Handler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string `conf:"ADDR" default:":8080"`
CertString string `conf:"CERT_STRING"`
KeyString string `conf:"KEY_STRING"`
ReadHeaderTimeout time.Duration `conf:"READ_HEADER_TIMEOUT" default:"5s"`
ReadTimeout time.Duration `conf:"READ_TIMEOUT" default:"10s"`
WriteTimeout time.Duration `conf:"WRITE_TIMEOUT" default:"10s"`
IdleTimeout time.Duration `conf:"IDLE_TIMEOUT" default:"120s"`
InitializationTimeout time.Duration `conf:"INIT_TIMEOUT" default:"25s"`
GracefulShutdownTimeout time.Duration `conf:"SHUTDOWN_TIMEOUT" default:"5s"`
HealthCheckEnabled bool `conf:"HEALTH_CHECK" default:"true"`
OpenApiEnabled bool `conf:"OPENAPI" default:"true"`
ProfilingEnabled bool `conf:"PROFILING" default:"false"`
}
type Context ¶
type Context struct {
Request *http.Request
ResponseWriter http.ResponseWriter
Results Results
// contains filtered or unexported fields
}
func (*Context) UpdateContext ¶
type ContextKey ¶
type ContextKey string
type HandlerChain ¶
type HandlerChain []Handler
type HttpService ¶
type HttpService struct {
InnerServer *http.Server
InnerRouter *Router
InnerMetrics *Metrics
Config *Config
// contains filtered or unexported fields
}
func NewHttpService ¶
func NewHttpService( config *Config, router *Router, metricsProvider MetricsProvider, logger *slog.Logger, ) *HttpService
func (*HttpService) Router ¶
func (hs *HttpService) Router() *Router
func (*HttpService) Server ¶
func (hs *HttpService) Server() *http.Server
type Metrics ¶
type Metrics struct {
RequestsTotal *prometheus.CounterVec
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics(mp MetricsProvider) *Metrics
type MetricsProvider ¶
type MetricsProvider interface {
GetRegistry() *prometheus.Registry
}
type Middleware ¶
type Middleware func() Handler
type Result ¶
type Result struct {
InnerRedirectToUri string
results.Result
InnerBody []byte
InnerStatusCode int
}
func (Result) RedirectToUri ¶
func (Result) StatusCode ¶
func (Result) WithStatusCode ¶
type Route ¶
type Route struct {
Pattern *uris.Pattern
Handlers []Handler
MuxHandlerFunc func(http.ResponseWriter, *http.Request)
Spec RouteOpenApiSpec
}
func (*Route) HasDescription ¶
func (*Route) HasOperationId ¶
func (*Route) HasPathParameter ¶
func (*Route) HasQueryParameter ¶
func (*Route) HasRequestModel ¶
func (*Route) HasResponse ¶
func (*Route) HasSummary ¶
func (*Route) IsDeprecated ¶
type RouteOpenApiSpec ¶
type RouteOpenApiSpec struct {
OperationId string
Summary string
Description string
Tags []string
Requests []RouteOpenApiSpecRequest
Responses []RouteOpenApiSpecResponse
Deprecated bool
}
type RouteOpenApiSpecRequest ¶
type RouteOpenApiSpecRequest struct {
Model any
}
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) GetHandlers ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.