Documentation
¶
Index ¶
- Constants
- func AuthMiddleware(validator TokenValidator) func(next http.Handler) http.Handler
- func DoAcceptedResponse(ctx context.Context, Response interface{}, writer http.ResponseWriter)
- func DoBadRequestResponse(ctx context.Context, result RequestErrors, writer http.ResponseWriter)
- func DoErrorResponse(ctx context.Context, writer http.ResponseWriter)
- func DoForbiddenResponse(ctx context.Context, message string, writer http.ResponseWriter)
- func DoNotFoundResponse(ctx context.Context, message string, writer http.ResponseWriter)
- func DoOKListResponse[T any](ctx context.Context, items []T, page, resultsPerPage, totalResults int, ...)
- func DoOKResponse(ctx context.Context, Response interface{}, writer http.ResponseWriter)
- func DoTooManyRequestsResponse(ctx context.Context, message string, retryAfterSeconds int, ...)
- func DoUnauthorizedResponse(ctx context.Context, message string, writer http.ResponseWriter)
- func DriverOwnershipMiddleware(pathParam string) func(next http.Handler) http.Handler
- func EntitlementMiddleware(requiredEntitlement string) func(next http.Handler) http.Handler
- func NewRestAPI(logger zerolog.Logger, correlationIDGenerator correlation.IDGenerator, ...) http.Handler
- func ReduceDeadlineMiddleware(buffer time.Duration) func(next http.Handler) http.Handler
- func RequestLoggingMiddleware() func(next http.Handler) http.Handler
- func SensitiveClaimsFromContext(ctx context.Context) *auth.SensitiveClaims
- func SessionClaimsFromContext(ctx context.Context) *auth.SessionClaims
- func WrapWithSegment(segmentName string, handler http.Handler) http.Handler
- func ZerologLogAttachMiddleware(logger zerolog.Logger) func(next http.Handler) http.Handler
- type AcceptedResponse
- type ErrorResponse
- type FieldError
- type ForbiddenResponse
- type NotFoundResponse
- type OKListResponse
- type OKResponse
- type Pagination
- type RequestErrors
- type RestAPIConfig
- type RootRouters
- type TokenValidator
- type TooManyRequestsResponse
- type UnauthorizedResponse
Constants ¶
View Source
const ( StartTimeQueryParam = "startTime" EndTimeQueryParam = "endTime" PageQueryParam = "page" ResultsPerPageParam = "resultsPerPage" DefaultResultsPerPage int = 10 // Analytics query params GroupByQueryParam = "groupBy" GranularityQueryParam = "granularity" SeriesIDQueryParam = "seriesId" CarIDQueryParam = "carId" TrackIDQueryParam = "trackId" )
begin url parameters
View Source
const DriverIDPathParam = "driver_id"
begin path parameters
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(validator TokenValidator) func(next http.Handler) http.Handler
func DoAcceptedResponse ¶
func DoAcceptedResponse(ctx context.Context, Response interface{}, writer http.ResponseWriter)
func DoBadRequestResponse ¶
func DoBadRequestResponse(ctx context.Context, result RequestErrors, writer http.ResponseWriter)
func DoErrorResponse ¶
func DoErrorResponse(ctx context.Context, writer http.ResponseWriter)
func DoForbiddenResponse ¶
func DoForbiddenResponse(ctx context.Context, message string, writer http.ResponseWriter)
func DoNotFoundResponse ¶
func DoNotFoundResponse(ctx context.Context, message string, writer http.ResponseWriter)
func DoOKListResponse ¶
func DoOKResponse ¶
func DoOKResponse(ctx context.Context, Response interface{}, writer http.ResponseWriter)
func DoUnauthorizedResponse ¶
func DoUnauthorizedResponse(ctx context.Context, message string, writer http.ResponseWriter)
func EntitlementMiddleware ¶
func NewRestAPI ¶
func NewRestAPI(logger zerolog.Logger, correlationIDGenerator correlation.IDGenerator, routers RootRouters, cfg RestAPIConfig) http.Handler
func ReduceDeadlineMiddleware ¶
ReduceDeadlineMiddleware reduces existing context deadlines by the specified buffer. If no deadline exists, the context is passed through unchanged.
func SensitiveClaimsFromContext ¶
func SensitiveClaimsFromContext(ctx context.Context) *auth.SensitiveClaims
func SessionClaimsFromContext ¶
func SessionClaimsFromContext(ctx context.Context) *auth.SessionClaims
Types ¶
type AcceptedResponse ¶
type AcceptedResponse struct {
Response interface{} `json:"response"`
CorrelationID string `json:"correlationId"`
}
type ErrorResponse ¶
type FieldError ¶
type ForbiddenResponse ¶
type NotFoundResponse ¶
type OKListResponse ¶
type OKListResponse[T any] struct { Items []T `json:"items"` Pagination Pagination `json:"pagination"` CorrelationID string `json:"correlationId"` }
type OKResponse ¶
type OKResponse struct {
Response interface{} `json:"response"`
CorrelationID string `json:"correlationId"`
}
type Pagination ¶
type RequestErrors ¶
type RequestErrors struct {
Errors []string `json:"errors"`
FieldErrors []FieldError `json:"fieldErrors"`
CorrelationID string `json:"correlationId"`
}
func NewRequestErrors ¶
func NewRequestErrors() RequestErrors
func (RequestErrors) HasAnyError ¶
func (r RequestErrors) HasAnyError() bool
func (RequestErrors) WithError ¶
func (r RequestErrors) WithError(error string) RequestErrors
func (RequestErrors) WithFieldError ¶
func (r RequestErrors) WithFieldError(field, error string) RequestErrors
func (RequestErrors) WithFieldErrorCode ¶
func (r RequestErrors) WithFieldErrorCode(field, code string, params map[string]string) RequestErrors
type RestAPIConfig ¶
type RootRouters ¶
type TokenValidator ¶
type TokenValidator interface {
ValidateToken(ctx context.Context, tokenString string) (*auth.SessionClaims, *auth.SensitiveClaims, error)
}
type TooManyRequestsResponse ¶
type UnauthorizedResponse ¶
type UnauthorizedResponse struct {
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.