handlers

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FunctionNameCTXKey = struct{}{}

FunctionNameCTXKey is a context key which points to the location of the function name set bu the ExtractFunction middleware

Functions

func MakeDelete

func MakeDelete(sr consul.ServiceResolver, client nomad.Job, logger hclog.Logger, stats metrics.StatsD) http.HandlerFunc

MakeDelete creates a handler for deploying functions

func MakeDeploy

func MakeDeploy(client nomad.Job, providerConfig types.ProviderConfig, logger hclog.Logger, stats metrics.StatsD) http.HandlerFunc

MakeDeploy creates a handler for deploying functions

func MakeExtractFunctionMiddleWare

func MakeExtractFunctionMiddleWare(
	getVars func(*http.Request) map[string]string,
	next http.HandlerFunc) http.HandlerFunc

MakeExtractFunctionMiddleWare returns a middleware handler which validates the presence of the function name in the URI query.

func MakeHealthHandler added in v0.2.27

func MakeHealthHandler() http.HandlerFunc

MakeHealthHandler returns 200/OK when healthy

func MakeInfo added in v0.2.26

func MakeInfo(logger hclog.Logger, stats metrics.StatsD, version string) http.HandlerFunc

MakeInfo creates handler for /system/info endpoint

func MakeProxy

func MakeProxy(config ProxyConfig) http.HandlerFunc

MakeProxy creates a proxy for HTTP web requests which can be routed to a function.

func MakeReader

func MakeReader(client nomad.Job, logger hclog.Logger, stats metrics.StatsD) http.HandlerFunc

MakeReader implements the OpenFaaS reader handler

func MakeReplicationReader

func MakeReplicationReader(client nomad.Job, logger hclog.Logger, stats metrics.StatsD) http.HandlerFunc

MakeReplicationReader creates a replication reader handler

func MakeReplicationWriter

func MakeReplicationWriter(client nomad.Job, logger hclog.Logger, stats metrics.StatsD) http.HandlerFunc

MakeReplicationWriter creates a handler for scaling functions

func MakeSecretHandler added in v0.4.0

func MakeSecretHandler(vs *vault.VaultService, log hclog.Logger) http.HandlerFunc

Types

type HTTPProxyClient

type HTTPProxyClient struct {
	// contains filtered or unexported fields
}

HTTPProxyClient allows the calling of functions

func MakeProxyClient

func MakeProxyClient(timeout time.Duration, l hclog.Logger) *HTTPProxyClient

MakeProxyClient creates a new HTTPProxyClient

func (*HTTPProxyClient) CallAndReturnResponse

func (pc *HTTPProxyClient) CallAndReturnResponse(address string, body []byte, headers http.Header) (
	[]byte, http.Header, int, error)

CallAndReturnResponse calls the function and returns the response

func (*HTTPProxyClient) GetFunctionName

func (pc *HTTPProxyClient) GetFunctionName(r *http.Request) string

GetFunctionName returns the name of the function from the request vars

type MockProxyClient

type MockProxyClient struct {
	mock.Mock
}

MockProxyClient is a mock implementation of the ProxyClient

func (*MockProxyClient) CallAndReturnResponse

func (mp *MockProxyClient) CallAndReturnResponse(address string, body []byte, h http.Header) (
	[]byte, http.Header, int, error)

CallAndReturnResponse returns a mock response

func (*MockProxyClient) GetFunctionName

func (mp *MockProxyClient) GetFunctionName(r *http.Request) string

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is a http.Handler which implements the ability to call a downstream function

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type ProxyClient

type ProxyClient interface {
	GetFunctionName(*http.Request) string
	CallAndReturnResponse(address string, body []byte, headers http.Header) ([]byte, http.Header, int, error)
}

ProxyClient defines the interface for a client which calls faas functions

type ProxyConfig added in v0.2.23

type ProxyConfig struct {
	Client   ProxyClient
	Resolver consul.ServiceResolver
	Logger   hclog.Logger
	StatsD   *statsd.Client
	Timeout  time.Duration
}

type SecretsResponse added in v0.4.0

type SecretsResponse struct {
	StatusCode int
	Body       []byte
}

Jump to

Keyboard shortcuts

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