Documentation
¶
Index ¶
- Constants
- Variables
- func GetIdToken(headers http.Header) string
- func HttpStatusCodeToError(statusCode int) error
- func InitRequest(ctx context.Context, request *http.Request) (context.Context, error)
- func Jsonize(_ context.Context, request interface{}, err error) ([]byte, int)
- func LogResponseStats(ctx context.Context, _ interface{}, err error) ([]byte, int)
- type Endpoint
- type ErrBadRequest
- type ErrForbidden
- type ErrInternalServerError
- type ErrNotFound
- type ErrPaymentRequired
- type ErrRedirect
- type ErrUnauthorized
- type Handler
- type HandlerFunc
- type HttpServer
- type InFilter
- type OutFilter
- type Service
- type UserId
- type WsEndpoint
- type WsHandler
Constants ¶
View Source
const ( CtxApiStart = "__CTX_APISTART" CtxRequestId = "__CTX_REQUEST_ID" CtxDeviceId = "__CTX_DEVICE_ID" CtxRequestUser = "__CTX_REQUEST_USER" CtxRequestLog = "__CTX_REQUEST_LOGLINE" CtxRequestTags = "__CTX_REQUEST_TAGS" )
Variables ¶
View Source
var (
DURATION_SECONDS_BUCKET = []float64{0.0, 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 3.0, 5.0, 7.5, 10.0}
)
View Source
var DefaultOutChain = []OutFilter{Jsonize, LogResponseStats}
Functions ¶
func GetIdToken ¶
func HttpStatusCodeToError ¶
func InitRequest ¶
Types ¶
type ErrBadRequest ¶
type ErrBadRequest struct {
Message string `json:"message"`
}
func (ErrBadRequest) Error ¶
func (e ErrBadRequest) Error() string
func (ErrBadRequest) HttpCode ¶
func (e ErrBadRequest) HttpCode() int
type ErrForbidden ¶
type ErrForbidden struct {
Message string `json:"message"`
}
func (ErrForbidden) Error ¶
func (e ErrForbidden) Error() string
func (ErrForbidden) HttpCode ¶
func (e ErrForbidden) HttpCode() int
type ErrInternalServerError ¶
type ErrInternalServerError struct {
Message string `json:"message"`
}
func (ErrInternalServerError) Error ¶
func (e ErrInternalServerError) Error() string
func (ErrInternalServerError) HttpCode ¶
func (e ErrInternalServerError) HttpCode() int
type ErrNotFound ¶
type ErrNotFound struct {
Message string `json:"message"`
}
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
func (ErrNotFound) HttpCode ¶
func (e ErrNotFound) HttpCode() int
type ErrPaymentRequired ¶
type ErrPaymentRequired struct {
Message string `json:"message"`
}
func (ErrPaymentRequired) Error ¶
func (e ErrPaymentRequired) Error() string
func (ErrPaymentRequired) HttpCode ¶
func (e ErrPaymentRequired) HttpCode() int
type ErrRedirect ¶
type ErrRedirect struct {
RedirectUrl string
}
func (ErrRedirect) Error ¶
func (e ErrRedirect) Error() string
func (ErrRedirect) HttpCode ¶
func (e ErrRedirect) HttpCode() int
type ErrUnauthorized ¶
type ErrUnauthorized struct {
}
func (ErrUnauthorized) Error ¶
func (e ErrUnauthorized) Error() string
func (ErrUnauthorized) HttpCode ¶
func (e ErrUnauthorized) HttpCode() int
type Handler ¶
Handler deprecated is responsible to handle an http request. DO NOT USE DIRECTLY! Use WrapHandler(HandlerFunc) to have typed return values
func WrapHandler ¶
func WrapHandler[T any](handler HandlerFunc[T]) Handler
type HandlerFunc ¶
HandlerFunc is responsible to handle an http request
type HttpServer ¶
type HttpServer struct {
StopChan chan bool
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(service Service) *HttpServer
func (*HttpServer) StartAsync ¶
func (s *HttpServer) StartAsync(host string, port int)
func (*HttpServer) Stop ¶
func (s *HttpServer) Stop() error
type InFilter ¶
InFilter functions are executed before the handler. The output of any last non-nil
func GlobalAuthHandler ¶
GlobalAuthHandler is a middleware that checks for a valid JWT token in the Authorization header. Currently it supports Firebase and Auth0 JWT tokens (check auth_auth0.go and auth_firebase.go).
func StaticTokenAuthHandler ¶
StaticTokenAuthHandler return a handler that check for a token defined in the input map. Only the key is matched
type Service ¶
type Service interface {
StartupProbe(ctx context.Context, r *http.Request) (interface{}, error)
LivenessProbe(ctx context.Context, r *http.Request) (interface{}, error)
ReadinessProbe(ctx context.Context, r *http.Request) (interface{}, error)
Endpoints() map[string]map[string]Endpoint
WsEndpoints() map[string]WsEndpoint
DeploymentEnvironment() string
}
type WsEndpoint ¶
Click to show internal directories.
Click to hide internal directories.