{"modulePath":"github.com/hithereco/aws-lambda-go-api-proxy","version":"v0.14.0-1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package core\n\nPackage core provides utility methods that help convert proxy events into an http.Request and http.ResponseWriter\n\nPackage core provides utility methods that help convert ALB events into an http.Request and http.ResponseWriter\n\nPackage core provides utility methods that help convert proxy events into an http.Request and http.ResponseWriter\n\nPackage core provides utility methods that help convert proxy events into an http.Request and http.ResponseWriter\n\nPackage core provides utility methods that help convert proxy events into an http.Request and http.ResponseWriter\n\nPackage core provides utility methods that help convert proxy events into an http.Request and http.ResponseWriter\n\n## Constants\n\n```go\nconst (\n\t// CustomHostVariable is the name of the environment variable that contains\n\t// the custom hostname for the request. If this variable is not set the framework\n\t// reverts to `RequestContext.DomainName`. The value for a custom host should\n\t// include a protocol: http://my-custom.host.com\n\tCustomHostVariable = \"GO_API_HOST\"\n\n\t// APIGwContextHeader is the custom header key used to store the\n\t// API Gateway context. To access the Context properties use the\n\t// GetAPIGatewayContext method of the RequestAccessor object.\n\tAPIGwContextHeader = \"X-GoLambdaProxy-ApiGw-Context\"\n\n\t// APIGwStageVarsHeader is the custom header key used to store the\n\t// API Gateway stage variables. To access the stage variable values\n\t// use the GetAPIGatewayStageVars method of the RequestAccessor object.\n\tAPIGwStageVarsHeader = \"X-GoLambdaProxy-ApiGw-StageVars\"\n)\n```\n\n```go\nconst (\n\t// ALBContextHeader is the custom header key used to store the\n\t// ALB ELB context. To access the Context properties use the\n\t// GetALBContext method of the RequestAccessorALB object.\n\tALBContextHeader = \"X-GoLambdaProxy-ALB-Context\"\n)\n```\n\n## Functions\n\n```go\nfunc GatewayTimeout() events.APIGatewayProxyResponse\n```\nGatewayTimeout returns a dafault Gateway Timeout (504) response\n\n```go\nfunc GatewayTimeoutALB() events.ALBTargetGroupResponse\n```\n\n```go\nfunc GatewayTimeoutV2() events.APIGatewayV2HTTPResponse\n```\n\n```go\nfunc GetAPIGatewayContextFromContext(ctx context.Context) (events.APIGatewayProxyRequestContext, bool)\n```\nGetAPIGatewayContextFromContext retrieve APIGatewayProxyRequestContext from context.Context\n\n```go\nfunc GetAPIGatewayV2ContextFromContext(ctx context.Context) (events.APIGatewayV2HTTPRequestContext, bool)\n```\nGetAPIGatewayV2ContextFromContext retrieve APIGatewayProxyRequestContext from context.Context\n\n```go\nfunc GetRuntimeContextFromContext(ctx context.Context) (*lambdacontext.LambdaContext, bool)\n```\nGetRuntimeContextFromContext retrieve Lambda Runtime Context from context.Context\n\n```go\nfunc GetRuntimeContextFromContextALB(ctx context.Context) (*lambdacontext.LambdaContext, bool)\n```\nGetRuntimeContextFromContext retrieve Lambda Runtime Context from context.Context\n\n```go\nfunc GetRuntimeContextFromContextV2(ctx context.Context) (*lambdacontext.LambdaContext, bool)\n```\nGetRuntimeContextFromContextV2 retrieve Lambda Runtime Context from context.Context\n\n```go\nfunc GetStageVarsFromContext(ctx context.Context) (map[string]string, bool)\n```\nGetStageVarsFromContext retrieve stage variables from context\n\n```go\nfunc GetStageVarsFromContextV2(ctx context.Context) (map[string]string, bool)\n```\nGetStageVarsFromContextV2 retrieve stage variables from context\n\n```go\nfunc GetTargetGroupRequetFromContextALB(ctx context.Context) (events.ALBTargetGroupRequestContext, bool)\n```\nGetALBTargetGroupRequestFromContext retrieve ALBTargetGroupt from context.Context\n\n```go\nfunc NewLoggedError(format string, a ...interface{}) error\n```\nNewLoggedError generates a new error and logs it to stdout\n\n## Types\n\n```go\ntype ProxyResponseWriter struct {\n\t// contains filtered or unexported fields\n}\n```\nProxyResponseWriter implements http.ResponseWriter and adds the method necessary to return an events.APIGatewayProxyResponse object\n\n```go\nfunc NewProxyResponseWriter() *ProxyResponseWriter\n```\nNewProxyResponseWriter returns a new ProxyResponseWriter object. The object is initialized with an empty map of headers and a status code of -1\n\n```go\nfunc (r *ProxyResponseWriter) CloseNotify() \u003c-chan bool\n```\n\n```go\nfunc (r *ProxyResponseWriter) GetProxyResponse() (events.APIGatewayProxyResponse, error)\n```\nGetProxyResponse converts the data passed to the response writer into an events.APIGatewayProxyResponse object. Returns a populated proxy response object. If the response is invalid, for example has no headers or an invalid status code returns an error.\n\n```go\nfunc (r *ProxyResponseWriter) Header() http.Header\n```\nHeader implementation from the http.ResponseWriter interface.\n\n```go\nfunc (r *ProxyResponseWriter) Write(body []byte) (int, error)\n```\nWrite sets the response body in the object. If no status code was set before with the WriteHeader method it sets the status for the response to 200 OK.\n\n```go\nfunc (r *ProxyResponseWriter) WriteHeader(status int)\n```\nWriteHeader sets a status code for the response. This method is used for error responses.\n\n```go\ntype ProxyResponseWriterALB struct {\n\t// contains filtered or unexported fields\n}\n```\nProxyResponseWriter implements http.ResponseWriter and adds the method necessary to return an events.ALBTargetGroupResponse object\n\n```go\nfunc NewProxyResponseWriterALB() *ProxyResponseWriterALB\n```\nNewProxyResponseWriter returns a new ProxyResponseWriter object. The object is initialized with an empty map of headers and a status code of -1\n\n```go\nfunc (r *ProxyResponseWriterALB) CloseNotify() \u003c-chan bool\n```\n\n```go\nfunc (r *ProxyResponseWriterALB) GetProxyResponse() (events.ALBTargetGroupResponse, error)\n```\nGetProxyResponse converts the data passed to the response writer into an events.ALBTargetGroupResponse object. Returns a populated proxy response object. If the response is invalid, for example has no headers or an invalid status code returns an error.\n\n```go\nfunc (r *ProxyResponseWriterALB) Header() http.Header\n```\nHeader implementation from the http.ResponseWriter interface.\n\n```go\nfunc (r *ProxyResponseWriterALB) Write(body []byte) (int, error)\n```\nWrite sets the response body in the object. If no status code was set before with the WriteHeader method it sets the status for the response to 200 OK.\n\n```go\nfunc (r *ProxyResponseWriterALB) WriteHeader(status int)\n```\nWriteHeader sets a status code for the response. This method is used for error responses.\n\n```go\ntype ProxyResponseWriterV2 struct {\n\t// contains filtered or unexported fields\n}\n```\nProxyResponseWriterV2 implements http.ResponseWriter and adds the method necessary to return an events.APIGatewayProxyResponse object\n\n```go\nfunc NewProxyResponseWriterV2() *ProxyResponseWriterV2\n```\nNewProxyResponseWriter returns a new ProxyResponseWriter object. The object is initialized with an empty map of headers and a status code of -1\n\n```go\nfunc (r *ProxyResponseWriterV2) CloseNotify() \u003c-chan bool\n```\n\n```go\nfunc (r *ProxyResponseWriterV2) GetProxyResponse() (events.APIGatewayV2HTTPResponse, error)\n```\nGetProxyResponse converts the data passed to the response writer into an events.APIGatewayProxyResponse object. Returns a populated proxy response object. If the response is invalid, for example has no headers or an invalid status code returns an error.\n\n```go\nfunc (r *ProxyResponseWriterV2) Header() http.Header\n```\nHeader implementation from the http.ResponseWriter interface.\n\n```go\nfunc (r *ProxyResponseWriterV2) Write(body []byte) (int, error)\n```\nWrite sets the response body in the object. If no status code was set before with the WriteHeader method it sets the status for the response to 200 OK.\n\n```go\nfunc (r *ProxyResponseWriterV2) WriteHeader(status int)\n```\nWriteHeader sets a status code for the response. This method is used for error responses.\n\n```go\ntype RequestAccessor struct {\n\t// contains filtered or unexported fields\n}\n```\nRequestAccessor objects give access to custom API Gateway properties in the request.\n\n```go\nfunc (r *RequestAccessor) EventToRequest(req events.APIGatewayProxyRequest) (*http.Request, error)\n```\nEventToRequest converts an API Gateway proxy event into an http.Request object. Returns the populated request maintaining headers\n\n```go\nfunc (r *RequestAccessor) EventToRequestWithContext(ctx context.Context, req events.APIGatewayProxyRequest) (*http.Request, error)\n```\nEventToRequestWithContext converts an API Gateway proxy event and context into an http.Request object. Returns the populated http request with lambda context, stage variables and APIGatewayProxyRequestContext as part of its context. Access those using GetAPIGatewayContextFromContext, GetStageVarsFromContext and GetRuntimeContextFromContext functions in this package.\n\n```go\nfunc (r *RequestAccessor) GetAPIGatewayContext(req *http.Request) (events.APIGatewayProxyRequestContext, error)\n```\nGetAPIGatewayContext extracts the API Gateway context object from a request's custom header. Returns a populated events.APIGatewayProxyRequestContext object from the request.\n\n```go\nfunc (r *RequestAccessor) GetAPIGatewayStageVars(req *http.Request) (map[string]string, error)\n```\nGetAPIGatewayStageVars extracts the API Gateway stage variables from a request's custom header. Returns a map\\[string]string of the stage variables and their values from the request.\n\n```go\nfunc (r *RequestAccessor) ProxyEventToHTTPRequest(req events.APIGatewayProxyRequest) (*http.Request, error)\n```\nProxyEventToHTTPRequest converts an API Gateway proxy event into a http.Request object. Returns the populated http request with additional two custom headers for the stage variables and API Gateway context. To access these properties use the GetAPIGatewayStageVars and GetAPIGatewayContext method of the RequestAccessor object.\n\n```go\nfunc (r *RequestAccessor) StripBasePath(basePath string) string\n```\nStripBasePath instructs the RequestAccessor object that the given base path should be removed from the request path before sending it to the framework for routing. This is used when API Gateway is configured with base path mappings in custom domain names.\n\n```go\ntype RequestAccessorALB struct {\n\t// contains filtered or unexported fields\n}\n```\nRequestAccessorALB objects give access to custom ALB Target Group properties in the request.\n\n```go\nfunc (r *RequestAccessorALB) EventToRequest(req events.ALBTargetGroupRequest) (*http.Request, error)\n```\nEventToRequest converts an ALB TargetGroup event into an http.Request object. Returns the populated request maintaining headers\n\n```go\nfunc (r *RequestAccessorALB) EventToRequestWithContext(ctx context.Context, req events.ALBTargetGroupRequest) (*http.Request, error)\n```\nEventToRequestWithContext converts an ALB Target Group Request event and context into an http.Request object. Returns the populated http request with lambda context, ALB TargetGroup RequestContext as part of its context.\n\n```go\nfunc (r *RequestAccessorALB) GetContextALB(req *http.Request) (events.ALBTargetGroupRequestContext, error)\n```\nGetALBContext extracts the ALB context object from a request's custom header. Returns a populated events.ALBTargetGroupRequestContext object from the request.\n\n```go\nfunc (r *RequestAccessorALB) ProxyEventToHTTPRequest(req events.ALBTargetGroupRequest) (*http.Request, error)\n```\nProxyEventToHTTPRequest converts an ALB Target Group Request event into a http.Request object. Returns the populated http request with additional custom header for the ALB context. To access these properties use the GetALBContext method of the RequestAccessorALB object.\n\n```go\nfunc (r *RequestAccessorALB) StripBasePath(basePath string) string\n```\nStripBasePath instructs the RequestAccessor object that the given base path should be removed from the request path before sending it to the framework for routing. This is used when API Gateway is configured with base path mappings in custom domain names.\n\n```go\ntype RequestAccessorV2 struct {\n\t// contains filtered or unexported fields\n}\n```\nRequestAccessorV2 objects give access to custom API Gateway properties in the request.\n\n```go\nfunc (r *RequestAccessorV2) EventToRequest(req events.APIGatewayV2HTTPRequest) (*http.Request, error)\n```\nEventToRequest converts an API Gateway proxy event into an http.Request object. Returns the populated request maintaining headers\n\n```go\nfunc (r *RequestAccessorV2) EventToRequestWithContext(ctx context.Context, req events.APIGatewayV2HTTPRequest) (*http.Request, error)\n```\nEventToRequestWithContext converts an API Gateway proxy event and context into an http.Request object. Returns the populated http request with lambda context, stage variables and APIGatewayProxyRequestContext as part of its context. Access those using GetAPIGatewayContextFromContext, GetStageVarsFromContext and GetRuntimeContextFromContext functions in this package.\n\n```go\nfunc (r *RequestAccessorV2) GetAPIGatewayContextV2(req *http.Request) (events.APIGatewayV2HTTPRequestContext, error)\n```\nGetAPIGatewayContextV2 extracts the API Gateway context object from a request's custom header. Returns a populated events.APIGatewayProxyRequestContext object from the request.\n\n```go\nfunc (r *RequestAccessorV2) GetAPIGatewayStageVars(req *http.Request) (map[string]string, error)\n```\nGetAPIGatewayStageVars extracts the API Gateway stage variables from a request's custom header. Returns a map\\[string]string of the stage variables and their values from the request.\n\n```go\nfunc (r *RequestAccessorV2) ProxyEventToHTTPRequest(req events.APIGatewayV2HTTPRequest) (*http.Request, error)\n```\nProxyEventToHTTPRequest converts an API Gateway proxy event into a http.Request object. Returns the populated http request with additional two custom headers for the stage variables and API Gateway context. To access these properties use the GetAPIGatewayStageVars and GetAPIGatewayContext method of the RequestAccessor object.\n\n```go\nfunc (r *RequestAccessorV2) StripBasePath(basePath string) string\n```\nStripBasePath instructs the RequestAccessor object that the given base path should be removed from the request path before sending it to the framework for routing. This is used when API Gateway is configured with base path mappings in custom domain names.\n\n```go\ntype SwitchableAPIGatewayRequest struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewSwitchableAPIGatewayRequestV1(v *events.APIGatewayProxyRequest) *SwitchableAPIGatewayRequest\n```\nNewSwitchableAPIGatewayRequestV1 creates a new SwitchableAPIGatewayRequest from APIGatewayProxyRequest\n\n```go\nfunc NewSwitchableAPIGatewayRequestV2(v *events.APIGatewayV2HTTPRequest) *SwitchableAPIGatewayRequest\n```\nNewSwitchableAPIGatewayRequestV2 creates a new SwitchableAPIGatewayRequest from APIGatewayV2HTTPRequest\n\n```go\nfunc (s *SwitchableAPIGatewayRequest) MarshalJSON() ([]byte, error)\n```\nMarshalJSON is a pass through serialization\n\n```go\nfunc (s *SwitchableAPIGatewayRequest) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON is a switching serialization based on the presence of fields in the source JSON, multiValueQueryStringParameters for APIGatewayProxyRequest and rawQueryString for APIGatewayV2HTTPRequest.\n\n```go\nfunc (s *SwitchableAPIGatewayRequest) Version1() *events.APIGatewayProxyRequest\n```\nVersion1 returns the contained events.APIGatewayProxyRequest or nil\n\n```go\nfunc (s *SwitchableAPIGatewayRequest) Version2() *events.APIGatewayV2HTTPRequest\n```\nVersion2 returns the contained events.APIGatewayV2HTTPRequest or nil\n\n```go\ntype SwitchableAPIGatewayResponse struct {\n\t// contains filtered or unexported fields\n}\n```\nSwitchableAPIGatewayResponse is a container for an APIGatewayProxyResponse or an APIGatewayV2HTTPResponse object which handles serialization and deserialization and switching between the entities based on the presence of fields in the source JSON, multiValueQueryStringParameters for APIGatewayProxyResponse and rawQueryString for APIGatewayV2HTTPResponse. It also provides some simple switching functions (wrapped type switching.)\n\n```go\nfunc NewSwitchableAPIGatewayResponseV1(v *events.APIGatewayProxyResponse) *SwitchableAPIGatewayResponse\n```\nNewSwitchableAPIGatewayResponseV1 creates a new SwitchableAPIGatewayResponse from APIGatewayProxyResponse\n\n```go\nfunc NewSwitchableAPIGatewayResponseV2(v *events.APIGatewayV2HTTPResponse) *SwitchableAPIGatewayResponse\n```\nNewSwitchableAPIGatewayResponseV2 creates a new SwitchableAPIGatewayResponse from APIGatewayV2HTTPResponse\n\n```go\nfunc (s *SwitchableAPIGatewayResponse) MarshalJSON() ([]byte, error)\n```\nMarshalJSON is a pass through serialization\n\n```go\nfunc (s *SwitchableAPIGatewayResponse) UnmarshalJSON(b []byte) error\n```\nUnmarshalJSON is a switching serialization based on the presence of fields in the source JSON, statusCode to verify that it's either APIGatewayProxyResponse or APIGatewayV2HTTPResponse and then rawQueryString for to determine if it is APIGatewayV2HTTPResponse or not.\n\n```go\nfunc (s *SwitchableAPIGatewayResponse) Version1() *events.APIGatewayProxyResponse\n```\nVersion1 returns the contained events.APIGatewayProxyResponse or nil\n\n```go\nfunc (s *SwitchableAPIGatewayResponse) Version2() *events.APIGatewayV2HTTPResponse\n```\nVersion2 returns the contained events.APIGatewayV2HTTPResponse or nil\n\n","path":"github.com/hithereco/aws-lambda-go-api-proxy/core","name":"core","synopsis":"Package core provides utility methods that help convert proxy events into an http.Request and http.ResponseWriter","isRedistributable":true}
