Documentation
¶
Overview ¶
Package httpio handles encoding and decoding for http i/o. This package is used to standardize request and response handling.
Index ¶
- func CauseIsError(err error) bool
- func HasBadGateway(err error) bool
- func HasBadRequest(err error) bool
- func HasClientMessage(err error) bool
- func HasConflict(err error) bool
- func HasForbidden(err error) bool
- func HasGatewayTimeout(err error) bool
- func HasInternalServerError(err error) bool
- func HasMethodNotAllowed(err error) bool
- func HasNotFound(err error) bool
- func HasNotImplemented(err error) bool
- func HasRequestTimeout(err error) bool
- func HasServiceUnavailable(err error) bool
- func HasTooManyRequests(err error) bool
- func HasUnauthorized(err error) bool
- func HasUnprocessableEntity(err error) bool
- func Log(handler func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc
- func Message(err error) string
- func Messages(err error) []string
- func NewBadGateway() errors.Chain
- func NewBadGatewayMessage(message string) errors.Chain
- func NewBadGatewayMessageWithError(err error, message string) errors.Chain
- func NewBadGatewayMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewBadGatewayMessagef(format string, a ...any) errors.Chain
- func NewBadGatewayWithError(err error) errors.Chain
- func NewBadRequest() errors.Chain
- func NewBadRequestMessage(message string) errors.Chain
- func NewBadRequestMessageWithError(err error, message string) errors.Chain
- func NewBadRequestMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewBadRequestMessagef(format string, a ...any) errors.Chain
- func NewBadRequestWithError(err error) errors.Chain
- func NewConflict() errors.Chain
- func NewConflictMessage(message string) errors.Chain
- func NewConflictMessageWithError(err error, message string) errors.Chain
- func NewConflictMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewConflictMessagef(format string, a ...any) errors.Chain
- func NewConflictWithError(err error) errors.Chain
- func NewForbidden() errors.Chain
- func NewForbiddenMessage(message string) errors.Chain
- func NewForbiddenMessageWithError(err error, message string) errors.Chain
- func NewForbiddenMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewForbiddenMessagef(format string, a ...any) errors.Chain
- func NewForbiddenWithError(err error) errors.Chain
- func NewGatewayTimeout() errors.Chain
- func NewGatewayTimeoutMessage(message string) errors.Chain
- func NewGatewayTimeoutMessageWithError(err error, message string) errors.Chain
- func NewGatewayTimeoutMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewGatewayTimeoutMessagef(format string, a ...any) errors.Chain
- func NewGatewayTimeoutWithError(err error) errors.Chain
- func NewInternalServerError() errors.Chain
- func NewInternalServerErrorMessage(message string) errors.Chain
- func NewInternalServerErrorMessageWithError(err error, message string) errors.Chain
- func NewInternalServerErrorMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewInternalServerErrorMessagef(format string, a ...any) errors.Chain
- func NewInternalServerErrorWithError(err error) errors.Chain
- func NewMethodNotAllowed() errors.Chain
- func NewMethodNotAllowedMessage(message string) errors.Chain
- func NewMethodNotAllowedMessageWithError(err error, message string) errors.Chain
- func NewMethodNotAllowedMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewMethodNotAllowedMessagef(format string, a ...any) errors.Chain
- func NewMethodNotAllowedWithError(err error) errors.Chain
- func NewNotFound() errors.Chain
- func NewNotFoundMessage(message string) errors.Chain
- func NewNotFoundMessageWithError(err error, message string) errors.Chain
- func NewNotFoundMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewNotFoundMessagef(format string, a ...any) errors.Chain
- func NewNotFoundWithError(err error) errors.Chain
- func NewNotImplemented() errors.Chain
- func NewNotImplementedMessage(message string) errors.Chain
- func NewNotImplementedMessageWithError(err error, message string) errors.Chain
- func NewNotImplementedMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewNotImplementedMessagef(format string, a ...any) errors.Chain
- func NewNotImplementedWithError(err error) errors.Chain
- func NewRequestTimeout() errors.Chain
- func NewRequestTimeoutMessage(message string) errors.Chain
- func NewRequestTimeoutMessageWithError(err error, message string) errors.Chain
- func NewRequestTimeoutMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewRequestTimeoutMessagef(format string, a ...any) errors.Chain
- func NewRequestTimeoutWithError(err error) errors.Chain
- func NewServiceUnavailable() errors.Chain
- func NewServiceUnavailableMessage(message string) errors.Chain
- func NewServiceUnavailableMessageWithError(err error, message string) errors.Chain
- func NewServiceUnavailableMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewServiceUnavailableMessagef(format string, a ...any) errors.Chain
- func NewServiceUnavailableWithError(err error) errors.Chain
- func NewTooManyRequests() errors.Chain
- func NewTooManyRequestsMessage(message string) errors.Chain
- func NewTooManyRequestsMessageWithError(err error, message string) errors.Chain
- func NewTooManyRequestsMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewTooManyRequestsMessagef(format string, a ...any) errors.Chain
- func NewTooManyRequestsWithError(err error) errors.Chain
- func NewUnauthorized() errors.Chain
- func NewUnauthorizedMessage(message string) errors.Chain
- func NewUnauthorizedMessageWithError(err error, message string) errors.Chain
- func NewUnauthorizedMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewUnauthorizedMessagef(format string, a ...any) errors.Chain
- func NewUnauthorizedWithError(err error) errors.Chain
- func NewUnprocessableEntity() errors.Chain
- func NewUnprocessableEntityMessage(message string) errors.Chain
- func NewUnprocessableEntityMessageWithError(err error, message string) errors.Chain
- func NewUnprocessableEntityMessageWithErrorf(err error, format string, a ...any) errors.Chain
- func NewUnprocessableEntityMessagef(format string, a ...any) errors.Chain
- func NewUnprocessableEntityWithError(err error) errors.Chain
- func Param[T any](r *http.Request, param ParamType) (val T)
- func WithParams(next http.Handler) http.Handler
- type ClientMessage
- type Encoder
- func (e *Encoder) BadGateway(ctx context.Context) error
- func (e *Encoder) BadGatewayMessage(ctx context.Context, message string) error
- func (e *Encoder) BadGatewayMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) BadGatewayMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) BadGatewayMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) BadGatewayWithError(ctx context.Context, err error) error
- func (e *Encoder) BadRequest(ctx context.Context) error
- func (e *Encoder) BadRequestMessage(ctx context.Context, message string) error
- func (e *Encoder) BadRequestMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) BadRequestMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) BadRequestMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) BadRequestWithError(ctx context.Context, err error) error
- func (e *Encoder) ClientMessage(ctx context.Context, err error) error
- func (e *Encoder) Conflict(ctx context.Context) error
- func (e *Encoder) ConflictMessage(ctx context.Context, message string) error
- func (e *Encoder) ConflictMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) ConflictMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) ConflictMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) ConflictWithError(ctx context.Context, err error) error
- func (e *Encoder) Forbidden(ctx context.Context) error
- func (e *Encoder) ForbiddenMessage(ctx context.Context, message string) error
- func (e *Encoder) ForbiddenMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) ForbiddenMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) ForbiddenMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) ForbiddenWithError(ctx context.Context, err error) error
- func (e *Encoder) GatewayTimeout(ctx context.Context) error
- func (e *Encoder) GatewayTimeoutMessage(ctx context.Context, message string) error
- func (e *Encoder) GatewayTimeoutMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) GatewayTimeoutMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) GatewayTimeoutMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) GatewayTimeoutWithError(ctx context.Context, err error) error
- func (e *Encoder) InternalServerError(ctx context.Context) error
- func (e *Encoder) InternalServerErrorMessage(ctx context.Context, message string) error
- func (e *Encoder) InternalServerErrorMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) InternalServerErrorMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) InternalServerErrorMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) InternalServerErrorWithError(ctx context.Context, err error) error
- func (e *Encoder) MethodNotAllowed(ctx context.Context) error
- func (e *Encoder) MethodNotAllowedMessage(ctx context.Context, message string) error
- func (e *Encoder) MethodNotAllowedMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) MethodNotAllowedMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) MethodNotAllowedMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) MethodNotAllowedWithError(ctx context.Context, err error) error
- func (e *Encoder) NotFound(ctx context.Context) error
- func (e *Encoder) NotFoundMessage(ctx context.Context, message string) error
- func (e *Encoder) NotFoundMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) NotFoundMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) NotFoundMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) NotFoundWithError(ctx context.Context, err error) error
- func (e *Encoder) NotImplemented(ctx context.Context) error
- func (e *Encoder) NotImplementedMessage(ctx context.Context, message string) error
- func (e *Encoder) NotImplementedMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) NotImplementedMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) NotImplementedMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) NotImplementedWithError(ctx context.Context, err error) error
- func (e *Encoder) Ok(body interface{}) error
- func (e *Encoder) RequestTimeout(ctx context.Context) error
- func (e *Encoder) RequestTimeoutMessage(ctx context.Context, message string) error
- func (e *Encoder) RequestTimeoutMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) RequestTimeoutMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) RequestTimeoutMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) RequestTimeoutWithError(ctx context.Context, err error) error
- func (e *Encoder) ServiceUnavailable(ctx context.Context) error
- func (e *Encoder) ServiceUnavailableMessage(ctx context.Context, message string) error
- func (e *Encoder) ServiceUnavailableMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) ServiceUnavailableMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) ServiceUnavailableMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) ServiceUnavailableWithError(ctx context.Context, err error) error
- func (e *Encoder) StatusCodeWithBody(statusCode int, body interface{}) error
- func (e *Encoder) TooManyRequests(ctx context.Context) error
- func (e *Encoder) TooManyRequestsMessage(ctx context.Context, message string) error
- func (e *Encoder) TooManyRequestsMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) TooManyRequestsMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) TooManyRequestsMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) TooManyRequestsWithError(ctx context.Context, err error) error
- func (e *Encoder) Unauthorized(ctx context.Context) error
- func (e *Encoder) UnauthorizedMessage(ctx context.Context, message string) error
- func (e *Encoder) UnauthorizedMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) UnauthorizedMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) UnauthorizedMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) UnauthorizedWithError(ctx context.Context, err error) error
- func (e *Encoder) UnprocessableEntity(ctx context.Context) error
- func (e *Encoder) UnprocessableEntityMessage(ctx context.Context, message string) error
- func (e *Encoder) UnprocessableEntityMessageWithError(ctx context.Context, err error, message string) error
- func (e *Encoder) UnprocessableEntityMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
- func (e *Encoder) UnprocessableEntityMessagef(ctx context.Context, format string, a ...any) error
- func (e *Encoder) UnprocessableEntityWithError(ctx context.Context, err error) error
- type HTTPEncoder
- type MessageResponse
- type ParamType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CauseIsError ¶ added in v0.2.0
CauseIsError returns true if the Cause of this error is an error vs a ClientMessage with nil error
func HasBadGateway ¶ added in v0.7.11
HasBadGateway checks if the error contains a BadGateway (502) message
func HasBadRequest ¶ added in v0.2.0
HasBadRequest checks if the error contains a BadRequest (400) message
func HasClientMessage ¶ added in v0.2.0
HasClientMessage checks if the error contains a client message
func HasConflict ¶ added in v0.2.0
HasConflict checks if the error contains a Conflict (409) message
func HasForbidden ¶ added in v0.2.0
HasForbidden checks if the error contains a Forbidden (403) message
func HasGatewayTimeout ¶ added in v0.7.11
HasGatewayTimeout checks if the error contains a GatewayTimeout (504) message
func HasInternalServerError ¶ added in v0.2.0
HasInternalServerError checks if the error contains an InternalServerError (500) message
func HasMethodNotAllowed ¶ added in v0.7.11
HasMethodNotAllowed checks if the error contains a MethodNotAllowed (405) message
func HasNotFound ¶ added in v0.2.0
HasNotFound checks if the error contains a NotFound (404) message
func HasNotImplemented ¶ added in v0.7.11
HasNotImplemented checks if the error contains a NotImplemented (501) message
func HasRequestTimeout ¶ added in v0.7.11
HasRequestTimeout checks if the error contains a RequestTimeout (408) message
func HasServiceUnavailable ¶ added in v0.2.0
HasServiceUnavailable checks if the error contains a ServiceUnavailable (503) message
func HasTooManyRequests ¶ added in v0.7.1
HasTooManyRequests checks if the error contains a TooManyRequests (429) message
func HasUnauthorized ¶ added in v0.2.0
HasUnauthorized checks if the error contains an Unauthorized (401) message
func HasUnprocessableEntity ¶ added in v0.7.11
HasUnprocessableEntity checks if the error contains a UnprocessableEntity (422) message
func Log ¶ added in v0.3.0
func Log(handler func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc
Log returns a http.HandlerFunc that logs any error coming from handlers. This provides a more ergonomic feel by allowing errors to be returned from handlers
Example usage:
func Handler() http.HandlerFunc {
return httpio.Log(func(w http.ResponseWriter, r *http.Request) error {
// do something
return errors.New("error")
})
}
func Message ¶ added in v0.2.0
Message returns the message from the wrapped ClientMessage or an empty string
func Messages ¶ added in v0.2.0
Messages returns a slice of messages from the ClientMessage's contained within the chain of errors
func NewBadGateway ¶ added in v0.7.11
NewBadGateway creates a new empty client message with a BadGateway (502) return code
func NewBadGatewayMessage ¶ added in v0.7.11
NewBadGatewayMessage creates a new client message with a BadGateway (502) return code
func NewBadGatewayMessageWithError ¶ added in v0.7.11
NewBadGatewayMessageWithError wraps an existing error while creating a new client message with a BadGateway (502) return code
func NewBadGatewayMessageWithErrorf ¶ added in v0.7.11
NewBadGatewayMessageWithErrorf wraps an existing error while creating a new client message with a BadGateway (502) return code
func NewBadGatewayMessagef ¶ added in v0.7.11
NewBadGatewayMessagef creates a new client message with a BadGateway (502) return code
func NewBadGatewayWithError ¶ added in v0.7.11
NewBadGatewayWithError wraps an existing error while creating a new empty client message and a BadGateway (502) return code
func NewBadRequest ¶ added in v0.2.0
NewBadRequest creates a new empty client message with a BadRequest (400) return code
func NewBadRequestMessage ¶ added in v0.2.0
NewBadRequestMessage creates a new client message with a BadRequest (400) return code
func NewBadRequestMessageWithError ¶ added in v0.2.0
NewBadRequestMessageWithError wraps an existing error while creating a new client message with a BadRequest (400) return code
func NewBadRequestMessageWithErrorf ¶ added in v0.2.0
NewBadRequestMessageWithErrorf wraps an existing error while creating a new client message with a BadRequest (400) return code
func NewBadRequestMessagef ¶ added in v0.2.0
NewBadRequestMessagef creates a new client message with a BadRequest (400) return code
func NewBadRequestWithError ¶ added in v0.2.0
NewBadRequestWithError wraps an existing error while creating a new empty client message and a BadRequest (400) return code
func NewConflict ¶ added in v0.2.0
NewConflict creates a new empty client message with a Conflict (409) return code
func NewConflictMessage ¶ added in v0.2.0
NewConflictMessage creates a new client message with a Conflict (409) return code
func NewConflictMessageWithError ¶ added in v0.2.0
NewConflictMessageWithError wraps an existing error while creating a new client message with a Conflict (409) return code
func NewConflictMessageWithErrorf ¶ added in v0.2.0
NewConflictMessageWithErrorf wraps an existing error while creating a new client message with a Conflict (409) return code
func NewConflictMessagef ¶ added in v0.2.0
NewConflictMessagef creates a new client message with a Conflict (409) return code
func NewConflictWithError ¶ added in v0.2.0
NewConflictWithError wraps an existing error while creating a new empty client message and a Conflict (409) return code
func NewForbidden ¶ added in v0.2.0
NewForbidden creates a new empty client message with a Forbidden (403) return code
func NewForbiddenMessage ¶ added in v0.2.0
NewForbiddenMessage creates a new client message with a Forbidden (403) return code
func NewForbiddenMessageWithError ¶ added in v0.2.0
NewForbiddenMessageWithError wraps an existing error while creating a new client message with a Forbidden (403) return code
func NewForbiddenMessageWithErrorf ¶ added in v0.2.0
NewForbiddenMessageWithErrorf wraps an existing error while creating a new client message with a Forbidden (403) return code
func NewForbiddenMessagef ¶ added in v0.2.0
NewForbiddenMessagef creates a new client message with a Forbidden (403) return code
func NewForbiddenWithError ¶ added in v0.2.0
NewForbiddenWithError wraps an existing error while creating a new empty client message and a Forbidden (403) return code
func NewGatewayTimeout ¶ added in v0.7.11
NewGatewayTimeout creates a new empty client message with a GatewayTimeout (504) return code
func NewGatewayTimeoutMessage ¶ added in v0.7.11
NewGatewayTimeoutMessage creates a new client message with a GatewayTimeout (504) return code
func NewGatewayTimeoutMessageWithError ¶ added in v0.7.11
NewGatewayTimeoutMessageWithError wraps an existing error while creating a new client message with a GatewayTimeout (504) return code
func NewGatewayTimeoutMessageWithErrorf ¶ added in v0.7.11
NewGatewayTimeoutMessageWithErrorf wraps an existing error while creating a new client message with a GatewayTimeout (504) return code
func NewGatewayTimeoutMessagef ¶ added in v0.7.11
NewGatewayTimeoutMessagef creates a new client message with a GatewayTimeout (504) return code
func NewGatewayTimeoutWithError ¶ added in v0.7.11
NewGatewayTimeoutWithError wraps an existing error while creating a new empty client message and a GatewayTimeout (504) return code
func NewInternalServerError ¶ added in v0.2.0
NewInternalServerError creates a new empty client message with a InternalServerError (500) return code
func NewInternalServerErrorMessage ¶ added in v0.2.0
NewInternalServerErrorMessage creates a new client message with a InternalServerError (500) return code
func NewInternalServerErrorMessageWithError ¶ added in v0.2.0
NewInternalServerErrorMessageWithError wraps an existing error while creating a new client message with a InternalServerError (500) return code
func NewInternalServerErrorMessageWithErrorf ¶ added in v0.2.0
NewInternalServerErrorMessageWithErrorf wraps an existing error while creating a new client message with a InternalServerError (500) return code
func NewInternalServerErrorMessagef ¶ added in v0.2.0
NewInternalServerErrorMessagef creates a new client message with a InternalServerError (500) return code
func NewInternalServerErrorWithError ¶ added in v0.2.0
NewInternalServerErrorWithError wraps an existing error while creating a new empty client message and a InternalServerError (500) return code
func NewMethodNotAllowed ¶ added in v0.7.11
NewMethodNotAllowed creates a new empty client message with a MethodNotAllowed (405) return code
func NewMethodNotAllowedMessage ¶ added in v0.7.11
NewMethodNotAllowedMessage creates a new client message with a MethodNotAllowed (405) return code
func NewMethodNotAllowedMessageWithError ¶ added in v0.7.11
NewMethodNotAllowedMessageWithError wraps an existing error while creating a new client message with a MethodNotAllowed (405) return code
func NewMethodNotAllowedMessageWithErrorf ¶ added in v0.7.11
NewMethodNotAllowedMessageWithErrorf wraps an existing error while creating a new client message with a MethodNotAllowed (405) return code
func NewMethodNotAllowedMessagef ¶ added in v0.7.11
NewMethodNotAllowedMessagef creates a new client message with a MethodNotAllowed (405) return code
func NewMethodNotAllowedWithError ¶ added in v0.7.11
NewMethodNotAllowedWithError wraps an existing error while creating a new empty client message and a MethodNotAllowed (405) return code
func NewNotFound ¶ added in v0.2.0
NewNotFound creates a new empty client message with a NotFound (404) return code
func NewNotFoundMessage ¶ added in v0.2.0
NewNotFoundMessage creates a new client message with a NotFound (404) return code
func NewNotFoundMessageWithError ¶ added in v0.2.0
NewNotFoundMessageWithError wraps an existing error while creating a new client message with a NotFound (404) return code
func NewNotFoundMessageWithErrorf ¶ added in v0.2.0
NewNotFoundMessageWithErrorf wraps an existing error while creating a new client message with a NotFound (404) return code
func NewNotFoundMessagef ¶ added in v0.2.0
NewNotFoundMessagef creates a new client message with a NotFound (404) return code
func NewNotFoundWithError ¶ added in v0.2.0
NewNotFoundWithError wraps an existing error while creating a new empty client message and a NotFound (404) return code
func NewNotImplemented ¶ added in v0.7.11
NewNotImplemented creates a new empty client message with a NotImplemented (501) return code
func NewNotImplementedMessage ¶ added in v0.7.11
NewNotImplementedMessage creates a new client message with a NotImplemented (501) return code
func NewNotImplementedMessageWithError ¶ added in v0.7.11
NewNotImplementedMessageWithError wraps an existing error while creating a new client message with a NotImplemented (501) return code
func NewNotImplementedMessageWithErrorf ¶ added in v0.7.11
NewNotImplementedMessageWithErrorf wraps an existing error while creating a new client message with a NotImplemented (501) return code
func NewNotImplementedMessagef ¶ added in v0.7.11
NewNotImplementedMessagef creates a new client message with a NotImplemented (501) return code
func NewNotImplementedWithError ¶ added in v0.7.11
NewNotImplementedWithError wraps an existing error while creating a new empty client message and a NotImplemented (501) return code
func NewRequestTimeout ¶ added in v0.7.11
NewRequestTimeout creates a new empty client message with a RequestTimeout (408) return code
func NewRequestTimeoutMessage ¶ added in v0.7.11
NewRequestTimeoutMessage creates a new client message with a RequestTimeout (408) return code
func NewRequestTimeoutMessageWithError ¶ added in v0.7.11
NewRequestTimeoutMessageWithError wraps an existing error while creating a new client message with a RequestTimeout (408) return code
func NewRequestTimeoutMessageWithErrorf ¶ added in v0.7.11
NewRequestTimeoutMessageWithErrorf wraps an existing error while creating a new client message with a RequestTimeout (408) return code
func NewRequestTimeoutMessagef ¶ added in v0.7.11
NewRequestTimeoutMessagef creates a new client message with a RequestTimeout (408) return code
func NewRequestTimeoutWithError ¶ added in v0.7.11
NewRequestTimeoutWithError wraps an existing error while creating a new empty client message and a RequestTimeout (408) return code
func NewServiceUnavailable ¶ added in v0.2.0
NewServiceUnavailable creates a new empty client message with a ServiceUnavailable (503) return code
func NewServiceUnavailableMessage ¶ added in v0.2.0
NewServiceUnavailableMessage creates a new client message with a ServiceUnavailable (503) return code
func NewServiceUnavailableMessageWithError ¶ added in v0.2.0
NewServiceUnavailableMessageWithError wraps an existing error while creating a new client message with a ServiceUnavailable (503) return code
func NewServiceUnavailableMessageWithErrorf ¶ added in v0.2.0
NewServiceUnavailableMessageWithErrorf wraps an existing error while creating a new client message with a ServiceUnavailable (503) return code
func NewServiceUnavailableMessagef ¶ added in v0.2.0
NewServiceUnavailableMessagef creates a new client message with a ServiceUnavailable (503) return code
func NewServiceUnavailableWithError ¶ added in v0.2.0
NewServiceUnavailableWithError wraps an existing error while creating a new empty client message and a ServiceUnavailable (503) return code
func NewTooManyRequests ¶ added in v0.7.1
NewTooManyRequests creates a new empty client message with a TooManyRequests (429) return code
func NewTooManyRequestsMessage ¶ added in v0.7.1
NewTooManyRequestsMessage creates a new client message with a TooManyRequests (429) return code
func NewTooManyRequestsMessageWithError ¶ added in v0.7.1
NewTooManyRequestsMessageWithError wraps an existing error while creating a new client message with a TooManyRequests (429) return code
func NewTooManyRequestsMessageWithErrorf ¶ added in v0.7.1
NewTooManyRequestsMessageWithErrorf wraps an existing error while creating a new client message with a TooManyRequests (429) return code
func NewTooManyRequestsMessagef ¶ added in v0.7.1
NewTooManyRequestsMessagef creates a new client message with a TooManyRequests (429) return code
func NewTooManyRequestsWithError ¶ added in v0.7.1
NewTooManyRequestsWithError wraps an existing error while creating a new empty client message and a TooManyRequests (429) return code
func NewUnauthorized ¶ added in v0.2.0
NewUnauthorized creates a new empty client message with a Unauthorized (401) return code
func NewUnauthorizedMessage ¶ added in v0.2.0
NewUnauthorizedMessage creates a new client message with a Unauthorized (401) return code
func NewUnauthorizedMessageWithError ¶ added in v0.2.0
NewUnauthorizedMessageWithError wraps an existing error while creating a new client message with a Unauthorized (401) return code
func NewUnauthorizedMessageWithErrorf ¶ added in v0.2.0
NewUnauthorizedMessageWithErrorf wraps an existing error while creating a new client message with a Unauthorized (401) return code
func NewUnauthorizedMessagef ¶ added in v0.2.0
NewUnauthorizedMessagef creates a new client message with a Unauthorized (401) return code
func NewUnauthorizedWithError ¶ added in v0.2.0
NewUnauthorizedWithError wraps an existing error while creating a new empty client message and a Unauthorized (401) return code
func NewUnprocessableEntity ¶ added in v0.7.11
NewUnprocessableEntity creates a new empty client message with a UnprocessableEntity (422) return code
func NewUnprocessableEntityMessage ¶ added in v0.7.11
NewUnprocessableEntityMessage creates a new client message with a UnprocessableEntity (422) return code
func NewUnprocessableEntityMessageWithError ¶ added in v0.7.11
NewUnprocessableEntityMessageWithError wraps an existing error while creating a new client message with a UnprocessableEntity (422) return code
func NewUnprocessableEntityMessageWithErrorf ¶ added in v0.7.11
NewUnprocessableEntityMessageWithErrorf wraps an existing error while creating a new client message with a UnprocessableEntity (422) return code
func NewUnprocessableEntityMessagef ¶ added in v0.7.11
NewUnprocessableEntityMessagef creates a new client message with a UnprocessableEntity (422) return code
func NewUnprocessableEntityWithError ¶ added in v0.7.11
NewUnprocessableEntityWithError wraps an existing error while creating a new empty client message and a UnprocessableEntity (422) return code
Types ¶
type ClientMessage ¶ added in v0.2.0
type ClientMessage struct {
// contains filtered or unexported fields
}
ClientMessage is a custom message type that can be used to return client messages
func (*ClientMessage) Error ¶ added in v0.2.0
func (c *ClientMessage) Error() string
Error returns the error message
func (*ClientMessage) Message ¶ added in v0.2.0
func (c *ClientMessage) Message() string
Message returns the client message
func (*ClientMessage) Unwrap ¶ added in v0.2.0
func (c *ClientMessage) Unwrap() error
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a struct that is used for encoding http responses
func NewEncoder ¶
func NewEncoder(w http.ResponseWriter) *Encoder
NewEncoder returns a new Encoder to write to the ResponseWriter This encoder will write to the ResponseWriter using a json encoder.
func (*Encoder) BadGateway ¶ added in v0.7.11
BadGateway creates a new empty client message with a BadGateway (502) return code
func (*Encoder) BadGatewayMessage ¶ added in v0.7.11
BadGatewayMessage creates a new client message with a BadGateway (502) return code
func (*Encoder) BadGatewayMessageWithError ¶ added in v0.7.11
BadGatewayMessageWithError wraps an existing error while creating a new client message with a BadGateway (502) return code
func (*Encoder) BadGatewayMessageWithErrorf ¶ added in v0.7.11
func (e *Encoder) BadGatewayMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
BadGatewayMessageWithErrorf wraps an existing error while creating a new client message with a BadGateway (502) return code
func (*Encoder) BadGatewayMessagef ¶ added in v0.7.11
BadGatewayMessagef creates a new client message with a BadGateway (502) return code
func (*Encoder) BadGatewayWithError ¶ added in v0.7.11
BadGatewayWithError wraps an existing error while creating a new empty client message and a BadGateway (502) return code
func (*Encoder) BadRequest ¶
BadRequest creates a new empty client message with a BadRequest (400) return code
func (*Encoder) BadRequestMessage ¶ added in v0.2.0
BadRequestMessage creates a new client message with a BadRequest (400) return code
func (*Encoder) BadRequestMessageWithError ¶ added in v0.2.0
BadRequestMessageWithError wraps an existing error while creating a new client message with a BadRequest (400) return code
func (*Encoder) BadRequestMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) BadRequestMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
BadRequestMessageWithErrorf wraps an existing error while creating a new client message with a BadRequest (400) return code
func (*Encoder) BadRequestMessagef ¶ added in v0.2.0
BadRequestMessagef creates a new client message with a BadRequest (400) return code
func (*Encoder) BadRequestWithError ¶ added in v0.2.0
BadRequestWithError wraps an existing error while creating a new empty client message and a BadRequest (400) return code
func (*Encoder) ClientMessage ¶ added in v0.2.0
ClientMessage sets an http code and formats a client message based upon the message type found in the error chain. If no message type is found it defaults to InternalServerError (500) with no message
func (*Encoder) Conflict ¶
Conflict creates a new empty client message with a Conflict (409) return code
func (*Encoder) ConflictMessage ¶ added in v0.2.0
ConflictMessage creates a new client message with a Conflict (409) return code
func (*Encoder) ConflictMessageWithError ¶ added in v0.2.0
ConflictMessageWithError wraps an existing error while creating a new client message with a Conflict (409) return code
func (*Encoder) ConflictMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) ConflictMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
ConflictMessageWithErrorf wraps an existing error while creating a new client message with a Conflict (409) return code
func (*Encoder) ConflictMessagef ¶ added in v0.2.0
ConflictMessagef creates a new client message with a Conflict (409) return code
func (*Encoder) ConflictWithError ¶ added in v0.2.0
ConflictWithError wraps an existing error while creating a new empty client message and a Conflict (409) return code
func (*Encoder) Forbidden ¶
Forbidden creates a new empty client message with a Forbidden (403) return code
func (*Encoder) ForbiddenMessage ¶ added in v0.2.0
ForbiddenMessage creates a new client message with a Forbidden (403) return code
func (*Encoder) ForbiddenMessageWithError ¶ added in v0.2.0
ForbiddenMessageWithError wraps an existing error while creating a new client message with a Forbidden (403) return code
func (*Encoder) ForbiddenMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) ForbiddenMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
ForbiddenMessageWithErrorf wraps an existing error while creating a new client message with a Forbidden (403) return code
func (*Encoder) ForbiddenMessagef ¶ added in v0.2.0
ForbiddenMessagef creates a new client message with a Forbidden (403) return code
func (*Encoder) ForbiddenWithError ¶ added in v0.2.0
ForbiddenWithError wraps an existing error while creating a new empty client message and a Forbidden (403) return code
func (*Encoder) GatewayTimeout ¶ added in v0.7.11
GatewayTimeout creates a new empty client message with a GatewayTimeout (504) return code
func (*Encoder) GatewayTimeoutMessage ¶ added in v0.7.11
GatewayTimeoutMessage creates a new client message with a GatewayTimeout (504) return code
func (*Encoder) GatewayTimeoutMessageWithError ¶ added in v0.7.11
func (e *Encoder) GatewayTimeoutMessageWithError(ctx context.Context, err error, message string) error
GatewayTimeoutMessageWithError wraps an existing error while creating a new client message with a GatewayTimeout (504) return code
func (*Encoder) GatewayTimeoutMessageWithErrorf ¶ added in v0.7.11
func (e *Encoder) GatewayTimeoutMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
GatewayTimeoutMessageWithErrorf wraps an existing error while creating a new client message with a GatewayTimeout (504) return code
func (*Encoder) GatewayTimeoutMessagef ¶ added in v0.7.11
GatewayTimeoutMessagef creates a new client message with a GatewayTimeout (504) return code
func (*Encoder) GatewayTimeoutWithError ¶ added in v0.7.11
GatewayTimeoutWithError wraps an existing error while creating a new empty client message and a GatewayTimeout (504) return code
func (*Encoder) InternalServerError ¶
InternalServerError creates a new empty client message with a InternalServerError (500) return code
func (*Encoder) InternalServerErrorMessage ¶ added in v0.2.0
InternalServerErrorMessage creates a new client message with a InternalServerError (500) return code
func (*Encoder) InternalServerErrorMessageWithError ¶ added in v0.2.0
func (e *Encoder) InternalServerErrorMessageWithError(ctx context.Context, err error, message string) error
InternalServerErrorMessageWithError wraps an existing error while creating a new client message with a InternalServerError (500) return code
func (*Encoder) InternalServerErrorMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) InternalServerErrorMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
InternalServerErrorMessageWithErrorf wraps an existing error while creating a new client message with a InternalServerError (500) return code
func (*Encoder) InternalServerErrorMessagef ¶ added in v0.2.0
InternalServerErrorMessagef creates a new client message with a InternalServerError (500) return code
func (*Encoder) InternalServerErrorWithError ¶ added in v0.2.0
InternalServerErrorWithError wraps an existing error while creating a new empty client message and a InternalServerError (500) return code
func (*Encoder) MethodNotAllowed ¶ added in v0.7.11
MethodNotAllowed creates a new empty client message with a MethodNotAllowed (405) return code
func (*Encoder) MethodNotAllowedMessage ¶ added in v0.7.11
MethodNotAllowedMessage creates a new client message with a MethodNotAllowed (405) return code
func (*Encoder) MethodNotAllowedMessageWithError ¶ added in v0.7.11
func (e *Encoder) MethodNotAllowedMessageWithError(ctx context.Context, err error, message string) error
MethodNotAllowedMessageWithError wraps an existing error while creating a new client message with a MethodNotAllowed (405) return code
func (*Encoder) MethodNotAllowedMessageWithErrorf ¶ added in v0.7.11
func (e *Encoder) MethodNotAllowedMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
MethodNotAllowedMessageWithErrorf wraps an existing error while creating a new client message with a MethodNotAllowed (405) return code
func (*Encoder) MethodNotAllowedMessagef ¶ added in v0.7.11
MethodNotAllowedMessagef creates a new client message with a MethodNotAllowed (405) return code
func (*Encoder) MethodNotAllowedWithError ¶ added in v0.7.11
MethodNotAllowedWithError wraps an existing error while creating a new empty client message and a MethodNotAllowed (405) return code
func (*Encoder) NotFound ¶
NotFound creates a new empty client message with a NotFound (404) return code
func (*Encoder) NotFoundMessage ¶ added in v0.2.0
NotFoundMessage creates a new client message with a NotFound (404) return code
func (*Encoder) NotFoundMessageWithError ¶ added in v0.2.0
NotFoundMessageWithError wraps an existing error while creating a new client message with a NotFound (404) return code
func (*Encoder) NotFoundMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) NotFoundMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
NotFoundMessageWithErrorf wraps an existing error while creating a new client message with a NotFound (404) return code
func (*Encoder) NotFoundMessagef ¶ added in v0.2.0
NotFoundMessagef creates a new client message with a NotFound (404) return code
func (*Encoder) NotFoundWithError ¶ added in v0.2.0
NotFoundWithError wraps an existing error while creating a new empty client message and a NotFound (404) return code
func (*Encoder) NotImplemented ¶ added in v0.7.11
NotImplemented creates a new empty client message with a NotImplemented (501) return code
func (*Encoder) NotImplementedMessage ¶ added in v0.7.11
NotImplementedMessage creates a new client message with a NotImplemented (501) return code
func (*Encoder) NotImplementedMessageWithError ¶ added in v0.7.11
func (e *Encoder) NotImplementedMessageWithError(ctx context.Context, err error, message string) error
NotImplementedMessageWithError wraps an existing error while creating a new client message with a NotImplemented (501) return code
func (*Encoder) NotImplementedMessageWithErrorf ¶ added in v0.7.11
func (e *Encoder) NotImplementedMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
NotImplementedMessageWithErrorf wraps an existing error while creating a new client message with a NotImplemented (501) return code
func (*Encoder) NotImplementedMessagef ¶ added in v0.7.11
NotImplementedMessagef creates a new client message with a NotImplemented (501) return code
func (*Encoder) NotImplementedWithError ¶ added in v0.7.11
NotImplementedWithError wraps an existing error while creating a new empty client message and a NotImplemented (501) return code
func (*Encoder) RequestTimeout ¶ added in v0.7.11
RequestTimeout creates a new empty client message with a RequestTimeout (408) return code
func (*Encoder) RequestTimeoutMessage ¶ added in v0.7.11
RequestTimeoutMessage creates a new client message with a RequestTimeout (408) return code
func (*Encoder) RequestTimeoutMessageWithError ¶ added in v0.7.11
func (e *Encoder) RequestTimeoutMessageWithError(ctx context.Context, err error, message string) error
RequestTimeoutMessageWithError wraps an existing error while creating a new client message with a RequestTimeout (408) return code
func (*Encoder) RequestTimeoutMessageWithErrorf ¶ added in v0.7.11
func (e *Encoder) RequestTimeoutMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
RequestTimeoutMessageWithErrorf wraps an existing error while creating a new client message with a RequestTimeout (408) return code
func (*Encoder) RequestTimeoutMessagef ¶ added in v0.7.11
RequestTimeoutMessagef creates a new client message with a RequestTimeout (408) return code
func (*Encoder) RequestTimeoutWithError ¶ added in v0.7.11
RequestTimeoutWithError wraps an existing error while creating a new empty client message and a RequestTimeout (408) return code
func (*Encoder) ServiceUnavailable ¶
ServiceUnavailable creates a new empty client message with a ServiceUnavailable (503) return code
func (*Encoder) ServiceUnavailableMessage ¶ added in v0.2.0
ServiceUnavailableMessage creates a new client message with a ServiceUnavailable (503) return code
func (*Encoder) ServiceUnavailableMessageWithError ¶ added in v0.2.0
func (e *Encoder) ServiceUnavailableMessageWithError(ctx context.Context, err error, message string) error
ServiceUnavailableMessageWithError wraps an existing error while creating a new client message with a ServiceUnavailable (503) return code
func (*Encoder) ServiceUnavailableMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) ServiceUnavailableMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
ServiceUnavailableMessageWithErrorf wraps an existing error while creating a new client message with a ServiceUnavailable (503) return code
func (*Encoder) ServiceUnavailableMessagef ¶ added in v0.2.0
ServiceUnavailableMessagef creates a new client message with a ServiceUnavailable (503) return code
func (*Encoder) ServiceUnavailableWithError ¶ added in v0.2.0
ServiceUnavailableWithError wraps an existing error while creating a new empty client message and a ServiceUnavailable (503) return code
func (*Encoder) StatusCodeWithBody ¶ added in v0.2.0
StatusCodeWithBody writes a statusCode and body
func (*Encoder) TooManyRequests ¶ added in v0.7.1
TooManyRequests creates a new empty client message with a TooManyRequests (429) return code
func (*Encoder) TooManyRequestsMessage ¶ added in v0.7.1
TooManyRequestsMessage creates a new client message with a TooManyRequests (429) return code
func (*Encoder) TooManyRequestsMessageWithError ¶ added in v0.7.1
func (e *Encoder) TooManyRequestsMessageWithError(ctx context.Context, err error, message string) error
TooManyRequestsMessageWithError wraps an existing error while creating a new client message with a TooManyRequests (429) return code
func (*Encoder) TooManyRequestsMessageWithErrorf ¶ added in v0.7.1
func (e *Encoder) TooManyRequestsMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
TooManyRequestsMessageWithErrorf wraps an existing error while creating a new client message with a TooManyRequests (429) return code
func (*Encoder) TooManyRequestsMessagef ¶ added in v0.7.1
TooManyRequestsMessagef creates a new client message with a TooManyRequests (429) return code
func (*Encoder) TooManyRequestsWithError ¶ added in v0.7.1
TooManyRequestsWithError wraps an existing error while creating a new client message with a TooManyRequests (429) return code
func (*Encoder) Unauthorized ¶
Unauthorized creates a new empty client message with a Unauthorized (401) return code
func (*Encoder) UnauthorizedMessage ¶ added in v0.2.0
UnauthorizedMessage creates a new client message with a Unauthorized (401) return code
func (*Encoder) UnauthorizedMessageWithError ¶ added in v0.2.0
func (e *Encoder) UnauthorizedMessageWithError(ctx context.Context, err error, message string) error
UnauthorizedMessageWithError wraps an existing error while creating a new client message with a Unauthorized (401) return code
func (*Encoder) UnauthorizedMessageWithErrorf ¶ added in v0.2.0
func (e *Encoder) UnauthorizedMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
UnauthorizedMessageWithErrorf wraps an existing error while creating a new client message with a Unauthorized (401) return code
func (*Encoder) UnauthorizedMessagef ¶ added in v0.2.0
UnauthorizedMessagef creates a new client message with a Unauthorized (401) return code
func (*Encoder) UnauthorizedWithError ¶ added in v0.2.0
UnauthorizedWithError wraps an existing error while creating a new empty client message and a Unauthorized (401) return code
func (*Encoder) UnprocessableEntity ¶ added in v0.7.11
UnprocessableEntity creates a new empty client message with a UnprocessableEntity (422) return code
func (*Encoder) UnprocessableEntityMessage ¶ added in v0.7.11
UnprocessableEntityMessage creates a new client message with a UnprocessableEntity (422) return code
func (*Encoder) UnprocessableEntityMessageWithError ¶ added in v0.7.11
func (e *Encoder) UnprocessableEntityMessageWithError(ctx context.Context, err error, message string) error
UnprocessableEntityMessageWithError wraps an existing error while creating a new client message with a UnprocessableEntity (422) return code
func (*Encoder) UnprocessableEntityMessageWithErrorf ¶ added in v0.7.11
func (e *Encoder) UnprocessableEntityMessageWithErrorf(ctx context.Context, err error, format string, a ...any) error
UnprocessableEntityMessageWithErrorf wraps an existing error while creating a new client message with a UnprocessableEntity (422) return code
func (*Encoder) UnprocessableEntityMessagef ¶ added in v0.7.11
UnprocessableEntityMessagef creates a new client message with a UnprocessableEntity (422) return code
type HTTPEncoder ¶
type HTTPEncoder interface {
// Encode is the call that is made to encode data into a response body and returns an error if it fails
Encode(v interface{}) error
}
HTTPEncoder is an interface that is accepted when encoding http responses
type MessageResponse ¶
type MessageResponse struct {
Message string `json:"message,omitempty"`
TraceID string `json:"traceId,omitempty"`
}
MessageResponse holds a standard structure for http responses that carry a single message This also includes a trace ID for debugging purposes