Documentation
¶
Index ¶
- func CheckRequestHandler[request any, response any](checkFunc func(request) (bool, string)) func(ctx *Context[request, response])
- func CheckResponseHandler[request any, response any](checkFunc func(response) (bool, string)) func(ctx *Context[request, response])
- func ExecuteChain[request any, response any](handlers Chain[request, response], ctx context.Context, req request, ...) (result response, err error)
- func LogInputAndOutputHandler[request any, response any](log logger.Logger, service string, handler string) func(ctx *Context[request, response])
- func RecoveryHandler[request any, response any](log logger.Logger, service string, handler string) func(ctx *Context[request, response])
- func RequestLimiterHandler[request any, response any](rpd, rpm, rps int) func(ctx *Context[request, response])
- func RequestLimiterHandlerWithFn[request any, response any](rpd, rpm, rps int, _ func(request) (response, error)) func(ctx *Context[request, response])
- type Chain
- func DefaultChain[request any, response any](logger logger.Logger, serviceName string, handlerName string, ...) Chain[request, response]
- func LimitedDefaultChain[request any, response any](logger logger.Logger, serviceName string, handlerName string, ...) Chain[request, response]
- func NewChain[request any, response any](handlers ...Handler[request, response]) Chain[request, response]
- type CheckRequestFailedError
- type CheckResponseFailedError
- type Context
- func (c *Context[request, response]) Abort()
- func (c *Context[request, response]) Deadline() (deadline time.Time, ok bool)
- func (c *Context[request, response]) Done() <-chan struct{}
- func (c *Context[request, response]) EntryGet(key string, receiver any, marshaller Marshaller) (err error)
- func (c *Context[request, response]) EntrySet(key string, payload any, marshaller Marshaller) (err error)
- func (c *Context[request, response]) Err() error
- func (c *Context[request, response]) Error() error
- func (c *Context[request, response]) FunctionGet(key string, fn func(val any))
- func (c *Context[request, response]) Get(key string) (value any, exists bool)
- func (c *Context[request, response]) GetBool(key string) (value bool, exists bool, isBool bool)
- func (c *Context[request, response]) GetContext() context.Context
- func (c *Context[request, response]) GetContextClientIP() (ip string, err error)
- func (c *Context[request, response]) GetFloat32(key string) (value float32, exists bool, isFloat32 bool)
- func (c *Context[request, response]) GetFloat64(key string) (value float64, exists bool, isFloat64 bool)
- func (c *Context[request, response]) GetInt(key string) (value int, exists bool, isInt bool)
- func (c *Context[request, response]) GetInt64(key string) (value int64, exists bool, isInt64 bool)
- func (c *Context[request, response]) GetRequest() request
- func (c *Context[request, response]) GetResponse() response
- func (c *Context[request, response]) GetString(key string) (value string, exists bool, isString bool)
- func (c *Context[request, response]) GetTime(key string) (value time.Time, exists bool, isTime bool)
- func (c *Context[request, response]) IsAborted() bool
- func (c *Context[request, response]) MustGet(key string, defaultVal any) any
- func (c *Context[request, response]) MustGetBool(key string, defaultVal bool) bool
- func (c *Context[request, response]) MustGetFloat32(key string, defaultVal float32) float32
- func (c *Context[request, response]) MustGetFloat64(key string, defaultVal float64) float64
- func (c *Context[request, response]) MustGetInt(key string, defaultVal int) int
- func (c *Context[request, response]) MustGetInt64(key string, defaultVal int64) int64
- func (c *Context[request, response]) MustGetString(key string, defaultVal string) string
- func (c *Context[request, response]) MustGetTime(key string, defaultVal time.Time) time.Time
- func (c *Context[request, response]) Next()
- func (c *Context[request, response]) Set(key string, value any)
- func (c *Context[request, response]) SetContext(ctx context.Context)
- func (c *Context[request, response]) SetError(err error)
- func (c *Context[request, response]) SetRequest(req request)
- func (c *Context[request, response]) SetResponse(resp response)
- func (c *Context[request, response]) SetResult(resp response, err error)
- func (c *Context[request, response]) TraceID() string
- func (c *Context[request, response]) Value(key any) any
- type Engine
- type GetRPCClientIPFailedError
- type Handler
- type InvalidIPAddressError
- type Marshaller
- type RequestLimiterError
- type ServerAlreadyServingError
- type Service
- type ServiceMetadata
- type UnsupportedNetworkError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRequestHandler ¶
func CheckResponseHandler ¶
func ExecuteChain ¶
func RecoveryHandler ¶
func RequestLimiterHandler ¶
Types ¶
type Chain ¶
func DefaultChain ¶
func LimitedDefaultChain ¶
func (Chain[request, response]) AddFrontHandler ¶
func (Chain[request, response]) AddHandler ¶
type CheckRequestFailedError ¶
type CheckRequestFailedError struct {
Reason string
}
func NewCheckRequestFailedError ¶
func NewCheckRequestFailedError(reason string) CheckRequestFailedError
func (CheckRequestFailedError) Error ¶
func (e CheckRequestFailedError) Error() string
type CheckResponseFailedError ¶
type CheckResponseFailedError struct {
Reason string
}
func NewCheckResponseFailedError ¶
func NewCheckResponseFailedError(reason string) CheckResponseFailedError
func (CheckResponseFailedError) Error ¶
func (e CheckResponseFailedError) Error() string
type Context ¶
func NewContext ¶
func (*Context[request, response]) Done ¶
func (c *Context[request, response]) Done() <-chan struct{}
func (*Context[request, response]) EntryGet ¶
func (c *Context[request, response]) EntryGet(key string, receiver any, marshaller Marshaller) (err error)
func (*Context[request, response]) EntrySet ¶
func (c *Context[request, response]) EntrySet(key string, payload any, marshaller Marshaller) (err error)
func (*Context[request, response]) FunctionGet ¶
func (*Context[request, response]) GetContext ¶
func (*Context[request, response]) GetContextClientIP ¶
func (*Context[request, response]) GetFloat32 ¶
func (*Context[request, response]) GetFloat64 ¶
func (*Context[request, response]) GetRequest ¶
func (c *Context[request, response]) GetRequest() request
func (*Context[request, response]) GetResponse ¶
func (c *Context[request, response]) GetResponse() response
func (*Context[request, response]) MustGetBool ¶
func (*Context[request, response]) MustGetFloat32 ¶
func (*Context[request, response]) MustGetFloat64 ¶
func (*Context[request, response]) MustGetInt ¶
func (*Context[request, response]) MustGetInt64 ¶
func (*Context[request, response]) MustGetString ¶
func (*Context[request, response]) MustGetTime ¶
func (*Context[request, response]) SetContext ¶
func (*Context[request, response]) SetRequest ¶
func (c *Context[request, response]) SetRequest(req request)
func (*Context[request, response]) SetResponse ¶
func (c *Context[request, response]) SetResponse(resp response)
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AddService ¶
func (*Engine) ServeAsync ¶
type GetRPCClientIPFailedError ¶
type GetRPCClientIPFailedError struct{}
func NewGetRPCClientIPFailedError ¶
func NewGetRPCClientIPFailedError() GetRPCClientIPFailedError
func (GetRPCClientIPFailedError) Error ¶
func (e GetRPCClientIPFailedError) Error() string
type InvalidIPAddressError ¶
type InvalidIPAddressError struct {
IPAddress string
}
func NewInvalidIPAddressError ¶
func NewInvalidIPAddressError(ipAddress string) InvalidIPAddressError
func (InvalidIPAddressError) Error ¶
func (e InvalidIPAddressError) Error() string
type Marshaller ¶
type Marshaller interface {
Marshal(request any) ([]byte, error)
Unmarshal(data []byte, response any) error
}
func NewJsonMarshaller ¶
func NewJsonMarshaller() Marshaller
func NewYamlMarshaller ¶
func NewYamlMarshaller() Marshaller
type RequestLimiterError ¶
type RequestLimiterError struct {
Reason string
}
func NewRequestLimiterError ¶
func NewRequestLimiterError(reason string) RequestLimiterError
func (RequestLimiterError) Error ¶
func (e RequestLimiterError) Error() string
type ServerAlreadyServingError ¶
type ServerAlreadyServingError struct {
Address string
}
func NewServerAlreadyServingError ¶
func NewServerAlreadyServingError(address string) ServerAlreadyServingError
func (ServerAlreadyServingError) Error ¶
func (e ServerAlreadyServingError) Error() string
type ServiceMetadata ¶
type ServiceMetadata struct {
ServiceName string
}
type UnsupportedNetworkError ¶
type UnsupportedNetworkError struct {
Network string
}
func NewUnsupportedNetworkError ¶
func NewUnsupportedNetworkError(network string) UnsupportedNetworkError
func (UnsupportedNetworkError) Error ¶
func (e UnsupportedNetworkError) Error() string
Click to show internal directories.
Click to hide internal directories.