interceptors

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 11 Imported by: 0

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

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

type DefaultStatusCodes struct {
	Success int
	Error   int
}

DefaultStatusCodes specifies the default return codes that will be used for successful and unsuccessful responses

type HTTPError added in v0.3.1

type HTTPError struct {
	StatusCode int
	StatusText string
}

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

func (*HTTPError) Error added in v0.3.1

func (e *HTTPError) Error() string

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

func DNSPrefetchControl(activate bool) Option

DNSPrefetchControl controls browser DNS prefetching

func FrameGuard added in v0.2.0

func FrameGuard(action string) Option

FrameGuard controls option to prevent clickjacking

func HTTPStrictTransportSecurity added in v0.3.1

func HTTPStrictTransportSecurity(maxAge int, includeSubDomains bool, preLoad bool) Option

HTTPStrictTransportSecurity controls option to set HTTPStrictTransportSecurity

func HidePoweredBy added in v0.2.0

func HidePoweredBy(with string) Option

HidePoweredBy controls option to remove the Server/X-Powered-By header

func IENoOpen added in v0.2.0

func IENoOpen(activate bool) Option

IENoOpen controls option to set X-Download-Options for IE8+

func NoSniff added in v0.2.0

func NoSniff(activate bool) Option

NoSniff controls option to keep clients from sniffing the MIME type

func ReferrerPolicy added in v0.2.0

func ReferrerPolicy(policy string) Option

ReferrerPolicy controls option to to hide the Referer header

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL