Documentation ¶
Index ¶
- Constants
- func BadRequest(err error, body interface{}) events.APIGatewayProxyResponse
- func FailureToGatewayResponse(err error) events.APIGatewayProxyResponse
- func GetAPIVersion(ctx context.Context) string
- func GetEvent(ctx context.Context) events.APIGatewayProxyRequest
- func GetIsCustomerServiceUser(ctx context.Context) bool
- func GetRoles(ctx context.Context) string
- func GetUserID(ctx context.Context) string
- func InitializeRequestContext(ctx context.Context, event events.APIGatewayProxyRequest) context.Context
- func LambdaStart(config RestHandlerConfig, h Handler, logger *zap.SugaredLogger)
- func ProcessFailure(err error, l *zap.SugaredLogger, req events.APIGatewayProxyRequest, ...) (events.APIGatewayProxyResponse, error)
- func ProcessSuccess(s *Success, l *zap.SugaredLogger, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func RequestLogger(ctx context.Context, l *zap.SugaredLogger, e events.APIGatewayProxyRequest) *zap.SugaredLogger
- func SetAPIVersion(ctx context.Context, version string) context.Context
- type ErrorResponse
- type Handler
- type RestHandlerConfig
- type RestRunner
- type Success
Constants ¶
const ( JsonMediaType = "application/json" PlainTextMediaType = "text/plain" HeaderAccessCtrlAllowOrigin = "Access-Control-Allow-Origin" HeaderContentType = "Content-Type" WildCardMediaType = "*/*" )
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(err error, body interface{}) events.APIGatewayProxyResponse
func FailureToGatewayResponse ¶
func FailureToGatewayResponse(err error) events.APIGatewayProxyResponse
func GetAPIVersion ¶
GetAPIVersion gets the api version from the context. Defaults to an empty string if not set.
func GetEvent ¶
func GetEvent(ctx context.Context) events.APIGatewayProxyRequest
GetEvent gets the apigw event from the context. Defaults to a new empty instance if not set.
func GetIsCustomerServiceUser ¶
GetIsCustomerServiceUser gets a boolean value on whether the user is a customer service user from the context. Defaults to false if not set.
func GetRoles ¶
GetRoles gets the users roles from the context. Defaults to an empty string if not set.
func GetUserID ¶
GetUserID gets the user id from the context. Defaults to an empty string if not set.
func LambdaStart ¶ added in v0.4.5
func LambdaStart(config RestHandlerConfig, h Handler, logger *zap.SugaredLogger)
func ProcessFailure ¶
func ProcessFailure(err error, l *zap.SugaredLogger, req events.APIGatewayProxyRequest, elapsed time.Duration) (events.APIGatewayProxyResponse, error)
func ProcessSuccess ¶
func ProcessSuccess(s *Success, l *zap.SugaredLogger, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
func RequestLogger ¶
func RequestLogger(ctx context.Context, l *zap.SugaredLogger, e events.APIGatewayProxyRequest) *zap.SugaredLogger
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message" ` Fields map[string]string `json:"fields,omitempty"` ID string `json:"id"` Status int `json:"status"` }
ErrorResponse is the type used when returning an error from a handler. Message is the error message ID is the request id that can be used to find request details in a logging repository.
type RestHandlerConfig ¶
type RestHandlerConfig struct {
sls.TimeoutConfig
}
type RestRunner ¶
type RestRunner struct {
// contains filtered or unexported fields
}
func NewRestRunner ¶ added in v0.4.5
func NewRestRunner(c RestHandlerConfig, h Handler, l *zap.SugaredLogger) *RestRunner
func (*RestRunner) Handle ¶
func (h *RestRunner) Handle(ctx context.Context, req events.APIGatewayProxyRequest) (out interface{}, err error)
type Success ¶
type Success struct { StatusCode int Headers map[string]string Body interface{} SuccessFn func(code int, body interface{}, l *zap.SugaredLogger, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) }