serverfullgw

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lambda

func Lambda(_ context.Context, _ string, _ string, _ string) (interface{}, error)

Lambda satisfies the transportd.NeComponent signature.

Types

type AWSSigner

type AWSSigner struct {
	Session *session.Session
	Signer  *v4.Signer
}

AWSSigner wraps the AWS specific signing process.

func (*AWSSigner) Sign

func (s *AWSSigner) Sign(r *http.Request, body io.ReadSeeker) error

Sign a request using the AWS algorithm.

type Component

type Component struct {
	Session *awsc.SessionComponent
}

Component implements the settings.Component interface.

func (*Component) New

func (c *Component) New(ctx context.Context, conf *Config) (func(http.RoundTripper) http.RoundTripper, error)

New creates the middleware.

func (*Component) Settings

func (c *Component) Settings() *Config

Settings returns a config with defaults set.

type Config

type Config struct {
	ARN          string `description:"Name/ARN of the lambda to invoke."`
	Async        bool   `description:"Fire and forget rather than wait for a response."`
	Request      string `description:"Template string to transform incoming requests to Lambda requests."`
	Success      string `description:"Template string to transform a success response into a proxy response."`
	Error        string `description:"Template string to transform a Lambda error response into a proxy response."`
	Authenticate bool   `description:"Whether or not to use AWS authentication in a request."`
	Session      *awsc.SessionConfig
}

Config contains all settings for the lambda plugin.

func (*Config) Name

func (*Config) Name() string

Name of the config root.

type LambdaTransport

type LambdaTransport struct {
	Wrapped                 http.RoundTripper
	URLParamFn              func(context.Context) map[string]string
	Name                    string
	Async                   bool
	RequestTemplate         *template.Template
	ResponseSuccessTemplate *template.Template
	ResponseErrorTemplate   *template.Template
	Signer                  Signer
}

LambdaTransport is a decorator that rewrites a request into a call to the AWS Lambda Invoke API.

func (*LambdaTransport) RoundTrip

func (r *LambdaTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip converts an incoming request to a Lambda Invoke API call.

type MultiMap

type MultiMap map[string][]string

MultiMap adds a helper for extracting the first element of a slice of values. This is a stand-in for the url.Value and http.Query types which are map[string][]string.

func (MultiMap) Get

func (m MultiMap) Get(name string) string

Get the first matching value or an empty string.

type NOPSigner

type NOPSigner struct{}

NOPSigner does nothing and is used for backwards compatibility.

func (*NOPSigner) Sign

func (s *NOPSigner) Sign(r *http.Request, body io.ReadSeeker) error

Sign a request by doing nothing.

type Request

type Request struct {
	Query  MultiMap
	Header MultiMap
	URL    map[string]string
	Body   map[string]interface{}
}

Request is a container for all available HTTP request values in a template.

func NewRequest

func NewRequest(urlParamFn func(context.Context) map[string]string, r *http.Request) (Request, error)

NewRequest converts an http.Request into a template Request.

type Response

type Response struct {
	Header MultiMap
	Body   map[string]interface{}
	Status int
}

Response is a container for all available response values in a template.

func NewResponse

func NewResponse(r *http.Response) (Response, error)

NewResponse converts an http.Response into a template Response.

type Signer

type Signer interface {
	Sign(r *http.Request, body io.ReadSeeker) error
}

Signer represents the AWS request signing process.

type TemplateContext

type TemplateContext struct {
	Request Request
	// Response is only populated when rendering a response template
	// and contains the unmarshalled JSON from the Lambda response.
	Response Response
}

TemplateContext is the value given as the root object context when rendering a template.

type TransportResponse

type TransportResponse struct {
	Status      int                 `json:"status"`
	Header      map[string][]string `json:"header"`
	Passthrough bool                `json:"bodyPassthrough"`
	Body        json.RawMessage     `json:"body"`
}

TransportResponse is used to unmarshal the rendered response template.

Jump to

Keyboard shortcuts

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