Documentation ¶
Overview ¶
Generic command dispatcher boilerplate. Takes in POST /api/command/... request and dispatches it to the command handler, and submits possible events to an event log.
Index ¶
- Constants
- type HttpError
- func InvokeSkippingAuthorization(cmdStruct command.Command, ctx *command.Ctx, invoker command.Invoker, ...) *HttpError
- func NewHttpError(statusCode int, errorCode string, description string) *HttpError
- func Serve(w http.ResponseWriter, r *http.Request, mwares httpauth.MiddlewareChainMap, ...) *HttpError
Constants ¶
View Source
const (
CreatedRecordIdHeaderKey = "x-created-record-id"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpError ¶
type HttpError struct { StatusCode int // if 0, means errored but error response already sent by middleware ErrorCode string Description string }
error that is sent as a JSON-formatted error
func InvokeSkippingAuthorization ¶
func InvokeSkippingAuthorization( cmdStruct command.Command, ctx *command.Ctx, invoker command.Invoker, eventLog eventlog.Log, ) *HttpError
validates command, invokes it and pushes raised events to event log
"SkippingAuthorization" suffix to warn that no authorization checks are performed (i.e. this should only be used for events not triggered by user)
func NewHttpError ¶
func Serve ¶
func Serve( w http.ResponseWriter, r *http.Request, mwares httpauth.MiddlewareChainMap, commandName string, allocators command.Allocators, invoker command.Invoker, eventLog eventlog.Log, ) *HttpError
func (*HttpError) ErrorResponseAlreadySentByMiddleware ¶
Click to show internal directories.
Click to hide internal directories.