server

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRouteMethod = http.MethodGet
	DefaultRoutePath   = "/"

	DefaultCorsOrigin  = "*"
	DefaultCorsMethods = "*"
	DefaultCorsHeaders = "*"

	DefaultShutdownTimeout = 10 * time.Second
	DefaultShutdownHandler = true
)

Variables

Functions

This section is empty.

Types

type CorsOption

type CorsOption func(*cors)

func WithCorsHeaders

func WithCorsHeaders(headers string) CorsOption

func WithCorsMethods

func WithCorsMethods(methods string) CorsOption

func WithCorsOrigin

func WithCorsOrigin(origin string) CorsOption

type Manager added in v0.4.0

type Manager interface {
	SetListener(listener net.Listener) Manager
	SetCore(core *fasthttp.Server) Manager
	SetRouter(router *fasthttpRouter.Router) Manager
	SetTelemetryManager(telemetry telemetry.Manager) Manager
	EnableTLS(tls *TLS) Manager
	AddMiddleware(MiddlewareHandler) Manager
	AddRoute(opts ...RouteOption) Manager
	AddRouteGroup(opts ...RouteGroupOption) Manager
	UseCors(opts ...CorsOption) Manager
	UseSwagger() Manager
	UseProfiling() Manager
	Listen() <-chan error
	Up()
	GetShutdownTimeout() time.Duration
	GetShutdownHandler() bool
	Shutdown(ctx context.Context, code int) error
}

func New

func New(opts ...Option) (Manager, error)

type MiddlewareHandler

type MiddlewareHandler func(RequestHandler) RequestHandler

type MockManager added in v0.11.0

type MockManager struct {
	mock.Mock
}

MockManager is an autogenerated mock type for the Manager type

func NewMockManager added in v0.11.0

func NewMockManager(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockManager

NewMockManager creates a new instance of MockManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockManager) AddMiddleware added in v0.11.0

func (_mock *MockManager) AddMiddleware(middlewareHandler MiddlewareHandler) Manager

AddMiddleware provides a mock function for the type MockManager

func (*MockManager) AddRoute added in v0.11.0

func (_mock *MockManager) AddRoute(opts ...RouteOption) Manager

AddRoute provides a mock function for the type MockManager

func (*MockManager) AddRouteGroup added in v0.11.0

func (_mock *MockManager) AddRouteGroup(opts ...RouteGroupOption) Manager

AddRouteGroup provides a mock function for the type MockManager

func (*MockManager) EXPECT added in v0.11.0

func (_m *MockManager) EXPECT() *MockManager_Expecter

func (*MockManager) EnableTLS added in v0.11.0

func (_mock *MockManager) EnableTLS(tls *TLS) Manager

EnableTLS provides a mock function for the type MockManager

func (*MockManager) GetShutdownHandler added in v0.11.0

func (_mock *MockManager) GetShutdownHandler() bool

GetShutdownHandler provides a mock function for the type MockManager

func (*MockManager) GetShutdownTimeout added in v0.11.0

func (_mock *MockManager) GetShutdownTimeout() time.Duration

GetShutdownTimeout provides a mock function for the type MockManager

func (*MockManager) Listen added in v0.11.0

func (_mock *MockManager) Listen() <-chan error

Listen provides a mock function for the type MockManager

func (*MockManager) SetCore added in v0.11.0

func (_mock *MockManager) SetCore(core *fasthttp.Server) Manager

SetCore provides a mock function for the type MockManager

func (*MockManager) SetListener added in v0.11.0

func (_mock *MockManager) SetListener(listener net.Listener) Manager

SetListener provides a mock function for the type MockManager

func (*MockManager) SetRouter added in v0.11.0

func (_mock *MockManager) SetRouter(router1 *router.Router) Manager

SetRouter provides a mock function for the type MockManager

func (*MockManager) SetTelemetryManager added in v0.11.0

func (_mock *MockManager) SetTelemetryManager(telemetry1 telemetry.Manager) Manager

SetTelemetryManager provides a mock function for the type MockManager

func (*MockManager) Shutdown added in v0.11.0

func (_mock *MockManager) Shutdown(ctx context.Context, code int) error

Shutdown provides a mock function for the type MockManager

func (*MockManager) Up added in v0.11.0

func (_mock *MockManager) Up()

Up provides a mock function for the type MockManager

func (*MockManager) UseCors added in v0.11.0

func (_mock *MockManager) UseCors(opts ...CorsOption) Manager

UseCors provides a mock function for the type MockManager

func (*MockManager) UseProfiling added in v0.11.0

func (_mock *MockManager) UseProfiling() Manager

UseProfiling provides a mock function for the type MockManager

func (*MockManager) UseSwagger added in v0.11.0

func (_mock *MockManager) UseSwagger() Manager

UseSwagger provides a mock function for the type MockManager

type MockManager_AddMiddleware_Call added in v0.11.0

type MockManager_AddMiddleware_Call struct {
	*mock.Call
}

MockManager_AddMiddleware_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddMiddleware'

func (*MockManager_AddMiddleware_Call) Return added in v0.11.0

func (*MockManager_AddMiddleware_Call) Run added in v0.11.0

func (*MockManager_AddMiddleware_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_AddMiddleware_Call) RunAndReturn(run func(middlewareHandler MiddlewareHandler) Manager) *MockManager_AddMiddleware_Call

type MockManager_AddRouteGroup_Call added in v0.11.0

type MockManager_AddRouteGroup_Call struct {
	*mock.Call
}

MockManager_AddRouteGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRouteGroup'

func (*MockManager_AddRouteGroup_Call) Return added in v0.11.0

func (*MockManager_AddRouteGroup_Call) Run added in v0.11.0

func (*MockManager_AddRouteGroup_Call) RunAndReturn added in v0.11.0

type MockManager_AddRoute_Call added in v0.11.0

type MockManager_AddRoute_Call struct {
	*mock.Call
}

MockManager_AddRoute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRoute'

func (*MockManager_AddRoute_Call) Return added in v0.11.0

func (*MockManager_AddRoute_Call) Run added in v0.11.0

func (*MockManager_AddRoute_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_AddRoute_Call) RunAndReturn(run func(opts ...RouteOption) Manager) *MockManager_AddRoute_Call

type MockManager_EnableTLS_Call added in v0.11.0

type MockManager_EnableTLS_Call struct {
	*mock.Call
}

MockManager_EnableTLS_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnableTLS'

func (*MockManager_EnableTLS_Call) Return added in v0.11.0

func (*MockManager_EnableTLS_Call) Run added in v0.11.0

func (*MockManager_EnableTLS_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_EnableTLS_Call) RunAndReturn(run func(tls *TLS) Manager) *MockManager_EnableTLS_Call

type MockManager_Expecter added in v0.11.0

type MockManager_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockManager_Expecter) AddMiddleware added in v0.11.0

func (_e *MockManager_Expecter) AddMiddleware(middlewareHandler interface{}) *MockManager_AddMiddleware_Call

AddMiddleware is a helper method to define mock.On call

  • middlewareHandler MiddlewareHandler

func (*MockManager_Expecter) AddRoute added in v0.11.0

func (_e *MockManager_Expecter) AddRoute(opts ...interface{}) *MockManager_AddRoute_Call

AddRoute is a helper method to define mock.On call

  • opts ...RouteOption

func (*MockManager_Expecter) AddRouteGroup added in v0.11.0

func (_e *MockManager_Expecter) AddRouteGroup(opts ...interface{}) *MockManager_AddRouteGroup_Call

AddRouteGroup is a helper method to define mock.On call

  • opts ...RouteGroupOption

func (*MockManager_Expecter) EnableTLS added in v0.11.0

func (_e *MockManager_Expecter) EnableTLS(tls interface{}) *MockManager_EnableTLS_Call

EnableTLS is a helper method to define mock.On call

  • tls *TLS

func (*MockManager_Expecter) GetShutdownHandler added in v0.11.0

GetShutdownHandler is a helper method to define mock.On call

func (*MockManager_Expecter) GetShutdownTimeout added in v0.11.0

GetShutdownTimeout is a helper method to define mock.On call

func (*MockManager_Expecter) Listen added in v0.11.0

Listen is a helper method to define mock.On call

func (*MockManager_Expecter) SetCore added in v0.11.0

func (_e *MockManager_Expecter) SetCore(core interface{}) *MockManager_SetCore_Call

SetCore is a helper method to define mock.On call

  • core *fasthttp.Server

func (*MockManager_Expecter) SetListener added in v0.11.0

func (_e *MockManager_Expecter) SetListener(listener interface{}) *MockManager_SetListener_Call

SetListener is a helper method to define mock.On call

  • listener net.Listener

func (*MockManager_Expecter) SetRouter added in v0.11.0

func (_e *MockManager_Expecter) SetRouter(router1 interface{}) *MockManager_SetRouter_Call

SetRouter is a helper method to define mock.On call

  • router1 *router.Router

func (*MockManager_Expecter) SetTelemetryManager added in v0.11.0

func (_e *MockManager_Expecter) SetTelemetryManager(telemetry1 interface{}) *MockManager_SetTelemetryManager_Call

SetTelemetryManager is a helper method to define mock.On call

  • telemetry1 telemetry.Manager

func (*MockManager_Expecter) Shutdown added in v0.11.0

func (_e *MockManager_Expecter) Shutdown(ctx interface{}, code interface{}) *MockManager_Shutdown_Call

Shutdown is a helper method to define mock.On call

  • ctx context.Context
  • code int

func (*MockManager_Expecter) Up added in v0.11.0

Up is a helper method to define mock.On call

func (*MockManager_Expecter) UseCors added in v0.11.0

func (_e *MockManager_Expecter) UseCors(opts ...interface{}) *MockManager_UseCors_Call

UseCors is a helper method to define mock.On call

  • opts ...CorsOption

func (*MockManager_Expecter) UseProfiling added in v0.11.0

UseProfiling is a helper method to define mock.On call

func (*MockManager_Expecter) UseSwagger added in v0.11.0

UseSwagger is a helper method to define mock.On call

type MockManager_GetShutdownHandler_Call added in v0.11.0

type MockManager_GetShutdownHandler_Call struct {
	*mock.Call
}

MockManager_GetShutdownHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetShutdownHandler'

func (*MockManager_GetShutdownHandler_Call) Return added in v0.11.0

func (*MockManager_GetShutdownHandler_Call) Run added in v0.11.0

func (*MockManager_GetShutdownHandler_Call) RunAndReturn added in v0.11.0

type MockManager_GetShutdownTimeout_Call added in v0.11.0

type MockManager_GetShutdownTimeout_Call struct {
	*mock.Call
}

MockManager_GetShutdownTimeout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetShutdownTimeout'

func (*MockManager_GetShutdownTimeout_Call) Return added in v0.11.0

func (*MockManager_GetShutdownTimeout_Call) Run added in v0.11.0

func (*MockManager_GetShutdownTimeout_Call) RunAndReturn added in v0.11.0

type MockManager_Listen_Call added in v0.11.0

type MockManager_Listen_Call struct {
	*mock.Call
}

MockManager_Listen_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Listen'

func (*MockManager_Listen_Call) Return added in v0.11.0

func (_c *MockManager_Listen_Call) Return(errCh <-chan error) *MockManager_Listen_Call

func (*MockManager_Listen_Call) Run added in v0.11.0

func (_c *MockManager_Listen_Call) Run(run func()) *MockManager_Listen_Call

func (*MockManager_Listen_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_Listen_Call) RunAndReturn(run func() <-chan error) *MockManager_Listen_Call

type MockManager_SetCore_Call added in v0.11.0

type MockManager_SetCore_Call struct {
	*mock.Call
}

MockManager_SetCore_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCore'

func (*MockManager_SetCore_Call) Return added in v0.11.0

func (*MockManager_SetCore_Call) Run added in v0.11.0

func (*MockManager_SetCore_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_SetCore_Call) RunAndReturn(run func(core *fasthttp.Server) Manager) *MockManager_SetCore_Call

type MockManager_SetListener_Call added in v0.11.0

type MockManager_SetListener_Call struct {
	*mock.Call
}

MockManager_SetListener_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetListener'

func (*MockManager_SetListener_Call) Return added in v0.11.0

func (*MockManager_SetListener_Call) Run added in v0.11.0

func (*MockManager_SetListener_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_SetListener_Call) RunAndReturn(run func(listener net.Listener) Manager) *MockManager_SetListener_Call

type MockManager_SetRouter_Call added in v0.11.0

type MockManager_SetRouter_Call struct {
	*mock.Call
}

MockManager_SetRouter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetRouter'

func (*MockManager_SetRouter_Call) Return added in v0.11.0

func (*MockManager_SetRouter_Call) Run added in v0.11.0

func (*MockManager_SetRouter_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_SetRouter_Call) RunAndReturn(run func(router1 *router.Router) Manager) *MockManager_SetRouter_Call

type MockManager_SetTelemetryManager_Call added in v0.11.0

type MockManager_SetTelemetryManager_Call struct {
	*mock.Call
}

MockManager_SetTelemetryManager_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTelemetryManager'

func (*MockManager_SetTelemetryManager_Call) Return added in v0.11.0

func (*MockManager_SetTelemetryManager_Call) Run added in v0.11.0

func (*MockManager_SetTelemetryManager_Call) RunAndReturn added in v0.11.0

type MockManager_Shutdown_Call added in v0.11.0

type MockManager_Shutdown_Call struct {
	*mock.Call
}

MockManager_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown'

func (*MockManager_Shutdown_Call) Return added in v0.11.0

func (*MockManager_Shutdown_Call) Run added in v0.11.0

func (*MockManager_Shutdown_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_Shutdown_Call) RunAndReturn(run func(ctx context.Context, code int) error) *MockManager_Shutdown_Call

type MockManager_Up_Call added in v0.11.0

type MockManager_Up_Call struct {
	*mock.Call
}

MockManager_Up_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Up'

func (*MockManager_Up_Call) Return added in v0.11.0

func (*MockManager_Up_Call) Run added in v0.11.0

func (_c *MockManager_Up_Call) Run(run func()) *MockManager_Up_Call

func (*MockManager_Up_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_Up_Call) RunAndReturn(run func()) *MockManager_Up_Call

type MockManager_UseCors_Call added in v0.11.0

type MockManager_UseCors_Call struct {
	*mock.Call
}

MockManager_UseCors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UseCors'

func (*MockManager_UseCors_Call) Return added in v0.11.0

func (*MockManager_UseCors_Call) Run added in v0.11.0

func (_c *MockManager_UseCors_Call) Run(run func(opts ...CorsOption)) *MockManager_UseCors_Call

func (*MockManager_UseCors_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_UseCors_Call) RunAndReturn(run func(opts ...CorsOption) Manager) *MockManager_UseCors_Call

type MockManager_UseProfiling_Call added in v0.11.0

type MockManager_UseProfiling_Call struct {
	*mock.Call
}

MockManager_UseProfiling_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UseProfiling'

func (*MockManager_UseProfiling_Call) Return added in v0.11.0

func (*MockManager_UseProfiling_Call) Run added in v0.11.0

func (*MockManager_UseProfiling_Call) RunAndReturn added in v0.11.0

type MockManager_UseSwagger_Call added in v0.11.0

type MockManager_UseSwagger_Call struct {
	*mock.Call
}

MockManager_UseSwagger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UseSwagger'

func (*MockManager_UseSwagger_Call) Return added in v0.11.0

func (*MockManager_UseSwagger_Call) Run added in v0.11.0

func (*MockManager_UseSwagger_Call) RunAndReturn added in v0.11.0

func (_c *MockManager_UseSwagger_Call) RunAndReturn(run func() Manager) *MockManager_UseSwagger_Call

type Option

type Option func(*server) error

func WithCore

func WithCore(core *fasthttp.Server) Option

func WithCoreOptions

func WithCoreOptions(opts ...core.Option) Option

func WithListener

func WithListener(listener net.Listener) Option

func WithListenerOptions

func WithListenerOptions(opts ...listener.Option) Option

func WithRouter

func WithRouter(router *fasthttpRouter.Router) Option

func WithRouterOptions

func WithRouterOptions(opts ...router.Option) Option

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

func WithTLS

func WithTLS(tls *TLS) Option

func WithTelemetryManager

func WithTelemetryManager(telemetry telemetry.Manager) Option

func WithoutShutdownHandler

func WithoutShutdownHandler() Option

type RequestContext

type RequestContext struct {
	*fasthttp.RequestCtx
}

func (*RequestContext) GetBearerToken

func (c *RequestContext) GetBearerToken() (string, error)

func (*RequestContext) GetContext

func (c *RequestContext) GetContext() context.Context

func (*RequestContext) GetHeaderStr

func (c *RequestContext) GetHeaderStr(key string) string

func (*RequestContext) GetIpAddr

func (c *RequestContext) GetIpAddr() string

func (*RequestContext) ReadJsonBody

func (c *RequestContext) ReadJsonBody(data any) error

func (*RequestContext) SetTraceIdHeader

func (c *RequestContext) SetTraceIdHeader()

func (*RequestContext) UserValueBool

func (c *RequestContext) UserValueBool(key any) (bool, error)

func (*RequestContext) UserValueInt

func (c *RequestContext) UserValueInt(key any) (int, error)

func (*RequestContext) UserValueStr

func (c *RequestContext) UserValueStr(key any) (string, error)

func (*RequestContext) UserValueStrBase64 added in v0.6.0

func (c *RequestContext) UserValueStrBase64(key any) (string, error)

func (*RequestContext) UserValueUint

func (c *RequestContext) UserValueUint(key any) (uint, error)

func (*RequestContext) Write

func (c *RequestContext) Write(p []byte) (int, error)

func (*RequestContext) WriteError

func (c *RequestContext) WriteError(err error)

func (*RequestContext) WriteJson

func (c *RequestContext) WriteJson(data any) error

func (*RequestContext) WriteJsonWithStatusCode

func (c *RequestContext) WriteJsonWithStatusCode(statusCode http.StatusCode, data any) error

func (*RequestContext) WriteStatusCode

func (c *RequestContext) WriteStatusCode(code http.StatusCode)

func (*RequestContext) WriteString

func (c *RequestContext) WriteString(s string) (int, error)

type RequestHandler

type RequestHandler func(*RequestContext)

type RouteGroupOption

type RouteGroupOption func(*routeGroup)

func WithRouteGroup

func WithRouteGroup(opts ...RouteGroupOption) RouteGroupOption

func WithRouteGroupMiddlewares

func WithRouteGroupMiddlewares(middlewares ...MiddlewareHandler) RouteGroupOption

func WithRouteGroupPath

func WithRouteGroupPath(path string) RouteGroupOption

func WithRouteGroupRoute

func WithRouteGroupRoute(opts ...RouteOption) RouteGroupOption

type RouteOption

type RouteOption func(*route)

func WithRouteBodyParserHandler

func WithRouteBodyParserHandler[T any](handler func(context.Context, *RequestContext, *T)) RouteOption

func WithRouteHandler

func WithRouteHandler(handler func(context.Context, *RequestContext)) RouteOption

func WithRouteMethod

func WithRouteMethod(method string) RouteOption

func WithRouteMiddlewares

func WithRouteMiddlewares(middlewares ...MiddlewareHandler) RouteOption

func WithRoutePath

func WithRoutePath(path string) RouteOption

type TLS

type TLS struct {
	Cert string
	Key  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL