Documentation ¶
Overview ¶
Package interceptors provides the building blocks of the functionality provided by GoIntercept All interceptors, native and custom, should be found under this package
Package interceptors provides the building blocks of the functionality provided by GoIntercept All interceptors, native and custom, should be found under this package
Index ¶
- func AddHeaders(headers map[string]string) gointercept.Interceptor
- func AddSecurityHeaders(options ...Option) gointercept.Interceptor
- func CreateAPIGatewayProxyResponse(defaultStatusCode *DefaultStatusCodes) gointercept.Interceptor
- func NormalizeHTTPRequestHeaders(canonical bool) gointercept.Interceptor
- func Notify(beforeMessage, afterMessage string) gointercept.Interceptor
- func ParseBody(input interface{}, allowUnknownFields bool) gointercept.Interceptor
- func ValidateBodyJSONSchema(schema string) gointercept.Interceptor
- type DefaultStatusCodes
- type HTTPError
- type Option
- func DNSPrefetchControl(activate bool) Option
- func FrameGuard(action string) Option
- func HTTPStrictTransportSecurity(maxAge int, includeSubDomains bool, preLoad bool) Option
- func HidePoweredBy(with string) Option
- func IENoOpen(activate bool) Option
- func NoSniff(activate bool) Option
- func ReferrerPolicy(policy string) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHeaders ¶
func AddHeaders(headers map[string]string) gointercept.Interceptor
AddHeaders attaches the given key-value mappings as HTTP headers to the given payload. It assumes that the payload is already an APIGatewayProxyResponse. Otherwise, no headers are added
func AddSecurityHeaders ¶ added in v0.2.0
func AddSecurityHeaders(options ...Option) gointercept.Interceptor
AddSecurityHeaders attaches default HTTP security headers to the output returned by the Lambda function. This is similar to the functionality offered by HelmetJS. For more information on the headers added by this interceptor check (https://helmetjs.github.io/)
Optionally, this interceptor's behavior can be customized by passing functions to activate, deactivate, or modify the functionality of the default headers. These functions include: DNSPrefetchControl, FrameGuard, HidePoweredBy, HTTPStrictTransportSecurity, IENoOpen, NoSniff, and ReferrerPolicy.
func CreateAPIGatewayProxyResponse ¶
func CreateAPIGatewayProxyResponse(defaultStatusCode *DefaultStatusCodes) gointercept.Interceptor
CreateAPIGatewayProxyResponse wraps the output of the Lambda function with an APIGatewayProxyResponse instance
func NormalizeHTTPRequestHeaders ¶ added in v0.4.0
func NormalizeHTTPRequestHeaders(canonical bool) gointercept.Interceptor
NormalizeHTTPRequestHeaders captures the headers (single and multi-value) sent in the API Gateway (HTTP) request and normalizes them to either an all-lowercase form or to their canonical form (content-type as opposed to Content-Type) based on the value of the given 'canonical' parameter.
func Notify ¶
func Notify(beforeMessage, afterMessage string) gointercept.Interceptor
Notify logs the given string parameters before and after the execution of the Lambda function
func ParseBody ¶ added in v0.4.0
func ParseBody(input interface{}, allowUnknownFields bool) gointercept.Interceptor
ParseBody parses the Lambda function's payload into the value pointed to by the input parameter
func ValidateBodyJSONSchema ¶ added in v0.4.0
func ValidateBodyJSONSchema(schema string) gointercept.Interceptor
ValidateBodyJSONSchema validates the given payload (in JSON format) against the given JSON schema.
For more information check: https://github.com/qri-io/jsonschema
Types ¶
type DefaultStatusCodes ¶
DefaultStatusCodes specifies the default return codes that will be used for successful and unsuccessful responses
type HTTPError ¶ added in v0.3.1
HTTPError represents a generic HTTP error. Specifies the error's code and status text that are used when creating and sending proper HTTP responses to the API consumer.
Optionally, an interceptor can throw this type of error with the corresponding code and status text. Then, the CreateAPIGatewayProxyResponse interceptor will create the appropriate API Gateway response used the information provided by it
type Option ¶ added in v0.2.0
type Option func(*securityHeaders)
Option represents a configuration option for the Headers interceptor
func DNSPrefetchControl ¶ added in v0.3.1
DNSPrefetchControl controls browser DNS prefetching
func FrameGuard ¶ added in v0.2.0
FrameGuard controls option to prevent clickjacking
func HTTPStrictTransportSecurity ¶ added in v0.3.1
HTTPStrictTransportSecurity controls option to set HTTPStrictTransportSecurity
func HidePoweredBy ¶ added in v0.2.0
HidePoweredBy controls option to remove the Server/X-Powered-By header
func ReferrerPolicy ¶ added in v0.2.0
ReferrerPolicy controls option to to hide the Referer header