Documentation ¶
Index ¶
- func CreateHandler[Req, Res any](endpoint Endpoint[Req, Res], requestHandler RequestHandler[Req], ...) http.HandlerFunc
- func EncodeToJSON(w http.ResponseWriter, obj interface{}, logger logging.Logger)
- func ErrorFromMessage(message APIErrorMessage) error
- func SendBadRequestResponse(w http.ResponseWriter, reqID string, logger logging.Logger, details string)
- func SendConflictResponse(w http.ResponseWriter, reqID string, logger logging.Logger, details string)
- func SendForbiddenResponse(w http.ResponseWriter, reqID string, logger logging.Logger, details string)
- func SendInternalServerError(w http.ResponseWriter, reqID string, logger logging.Logger, details string)
- func SendResponseWithStatusAndMessage(w http.ResponseWriter, status int, reqID string, message APIErrorMessage, ...)
- func SendStatusNotFoundResponse(w http.ResponseWriter, reqID string, logger logging.Logger, details string)
- func SendUnauthorizedResponse(w http.ResponseWriter, reqID string, logger logging.Logger, details string)
- type APIError
- type APIErrorMessage
- type AllClaims
- type CtxKeyAPIKey
- type CtxKeyAccessToken
- type CtxKeyAdminHeader
- type CtxKeyClaims
- type CtxKeyIdToken
- type CustomClaims
- type Endpoint
- type RequestHandler
- type ResponseHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateHandler ¶
func CreateHandler[Req, Res any](endpoint Endpoint[Req, Res], requestHandler RequestHandler[Req], responseHandler ResponseHandler[Res]) http.HandlerFunc
func EncodeToJSON ¶
func EncodeToJSON(w http.ResponseWriter, obj interface{}, logger logging.Logger)
func ErrorFromMessage ¶
func ErrorFromMessage(message APIErrorMessage) error
ErrorFromMessage will construct a new error that can hold a predefined error message.
func SendBadRequestResponse ¶
func SendConflictResponse ¶
func SendForbiddenResponse ¶
func SendInternalServerError ¶
func SendResponseWithStatusAndMessage ¶
func SendResponseWithStatusAndMessage(w http.ResponseWriter, status int, reqID string, message APIErrorMessage, logger logging.Logger, details string)
Types ¶
type APIError ¶
type APIError struct { RequestID string `json:"requestid"` Message APIErrorMessage `json:"message"` Timestamp int64 `json:"timestamp"` Details url.Values `json:"details"` }
APIError is the generic return type for any Failure during endpoint operations
func NewAPIError ¶
func NewAPIError(reqID string, message APIErrorMessage, details url.Values) *APIError
NewAPIError creates a new instance of the `APIError` which will be returned to the client if an operation fails
type APIErrorMessage ¶
type APIErrorMessage string
APIErrorMessage type holds predefined error message constructs for the clients
const ( // TransactionParseErrorMessage indicates a json body parse error TransactionParseErrorMessage APIErrorMessage = "transaction.parse.error" // field data failed to validate, see details field for more information TransactionDataInvalidMessage APIErrorMessage = "transaction.data.invalid" // duplicate referenceId TransactionDataDuplicateMessage APIErrorMessage = "transaction.data.duplicate" // database error TransactionWriteErrorMessage APIErrorMessage = "transaction.write.error" // database error TransactionReadErrorMessage APIErrorMessage = "transaction.read.error" // adapter failure while creating payment link TransactionPaylingErrorMessage APIErrorMessage = "transaction.paylink.error" // no such transaction in the database TransactionIDNotFoundMessage APIErrorMessage = "transaction.id.notfound" // syntactically invalid transaction id, must be positive integer TransactionIDInvalidMessage APIErrorMessage = "transaction.id.invalid" // deletion is not possible, e.g. because the grace period has expired for a valid payment TransactionCannotDeleteMessage APIErrorMessage = "transaction.cannot.delete" AuthUnauthorizedMessage APIErrorMessage = "auth.unauthorized" // permissions missing AuthForbiddenMessage APIErrorMessage = "auth.forbidden" // Request could not be parsed properly RequestParseErrorMessage APIErrorMessage = "request.parse.failed" // Request created a conflict RequestConflictMessage APIErrorMessage = "request.conflict" // Internal error InternalErrorMessage APIErrorMessage = "http.error.internal" // Unknown error UnknownErrorMessage APIErrorMessage = "http.error.unkonwn" )
type AllClaims ¶
type AllClaims struct { jwt.RegisteredClaims CustomClaims }
type CtxKeyAPIKey ¶
type CtxKeyAPIKey struct{}
type CtxKeyAccessToken ¶
type CtxKeyAccessToken struct{}
type CtxKeyAdminHeader ¶
type CtxKeyAdminHeader struct{}
TODO Remove after legacy system was replaced with 2FA See reference https://github.com/eurofurence/reg-payment-service/issues/57
type CtxKeyClaims ¶
type CtxKeyClaims struct{}
type CtxKeyIdToken ¶
type CtxKeyIdToken struct{}
type CustomClaims ¶
type ResponseHandler ¶
Click to show internal directories.
Click to hide internal directories.