Documentation ¶
Index ¶
- Constants
- func CorrelationIDHTTPMiddleware(next http.HandlerFunc) http.HandlerFunc
- func LogError(ctx context.Context, message string, fields ...any)
- func Map[TSource any, TResult any](source []TSource, m func(TSource) TResult) []TResult
- func RequestBody[TRequest any](r *http.Request) (TRequest, error)
- func Tx(ctx context.Context, db *sql.DB, ...) (err error)
- func WriteBadGateway(w http.ResponseWriter, r *http.Request, body any)
- func WriteBadRequest(w http.ResponseWriter, r *http.Request, body any)
- func WriteCommandError(w http.ResponseWriter, r *http.Request, err error, opts ...ResponseOption)
- func WriteCreated(w http.ResponseWriter, r *http.Request, location string, ...)
- func WriteInternalServerError(w http.ResponseWriter, r *http.Request, body any)
- func WriteOK(w http.ResponseWriter, r *http.Request, body any)
- func WriteResponse(w http.ResponseWriter, r *http.Request, statusCode int, body any, ...)
- func WriteUnauthorized(w http.ResponseWriter, r *http.Request, body any)
- type CommandError
- type CommandErrorOption
- type ContextKey
- type ContextSession
- type EmailClient
- type HandlerErrorLoggingBehavior
- type MailMessage
- type RequestLoggingBehavior
- type RequestValidationBehavior
- type ResponseOption
- type TransactionOption
- type Unit
- type ValidationError
- type Validator
Constants ¶
View Source
const ( CorrelationIDHeader = "Correlation-Id" CorrelationIDContextKey contextKey = "correlation_id" )
Variables ¶
This section is empty.
Functions ¶
func CorrelationIDHTTPMiddleware ¶
func CorrelationIDHTTPMiddleware(next http.HandlerFunc) http.HandlerFunc
func WriteBadGateway ¶
func WriteBadGateway(w http.ResponseWriter, r *http.Request, body any)
func WriteBadRequest ¶
func WriteBadRequest(w http.ResponseWriter, r *http.Request, body any)
func WriteCommandError ¶
func WriteCommandError(w http.ResponseWriter, r *http.Request, err error, opts ...ResponseOption)
func WriteCreated ¶
func WriteCreated(w http.ResponseWriter, r *http.Request, location string, opts ...ResponseOption)
func WriteInternalServerError ¶
func WriteInternalServerError(w http.ResponseWriter, r *http.Request, body any)
func WriteResponse ¶
func WriteResponse( w http.ResponseWriter, r *http.Request, statusCode int, body any, opts ...ResponseOption, )
func WriteUnauthorized ¶
func WriteUnauthorized(w http.ResponseWriter, r *http.Request, body any)
Types ¶
type CommandError ¶
func NewCommandError ¶
func NewCommandError(statusCode int, payload any, opts ...CommandErrorOption) CommandError
func (CommandError) Error ¶
func (r CommandError) Error() string
type CommandErrorOption ¶
type CommandErrorOption func(*CommandError)
func WithReason ¶
func WithReason(reason string) CommandErrorOption
type ContextSession ¶
func Session ¶
func Session(ctx context.Context) ContextSession
type EmailClient ¶
type EmailClient struct {
// contains filtered or unexported fields
}
func NewEmailClient ¶
func NewEmailClient( host *url.URL, auth smtp.Auth, ) *EmailClient
TODO: pass in smtp.Auth directly instead of username/password.
func (*EmailClient) Send ¶
func (c *EmailClient) Send(m MailMessage) error
type MailMessage ¶
type MailMessage struct { Subject string From string To []string Cc []string Bcc []string BodyString string IsHTML bool }
func (MailMessage) Content ¶
func (m MailMessage) Content() []byte
type RequestLoggingBehavior ¶
type RequestValidationBehavior ¶
type RequestValidationBehavior struct{}
type ResponseOption ¶
type ResponseOption func(http.ResponseWriter, *http.Request)
func WithBody ¶
func WithBody(body any) ResponseOption
func WithHeader ¶
func WithHeader(header, value string) ResponseOption
type TransactionOption ¶
func WithIsolationLevel ¶
func WithIsolationLevel(isolationLevel sql.IsolationLevel) TransactionOption
type ValidationError ¶
type ValidationError struct {
ValidationErrors []error
}
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.