middleware

package
v0.0.0-...-1ad4746 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingToken = errors.New("Missing token in auth request")

ErrMissingToken is returned by GetAuthFromRequest when JWT is missing.

Functions

func Auth

func Auth(next http.Handler, client *http.Client, nodeInfo nodeutil.NodeInfo, role string) http.Handler

Auth is a middleware that validates a user has a valid JWT to access the given endpoint.

func DownloadGzippedContent

func DownloadGzippedContent(next http.Handler, prefix string, vars ...string) http.Handler

DownloadGzippedContent is a middleware which sets Content-disposition header and makes a postfix for a downloadable item.

func FromContextConfig

func FromContextConfig(ctx context.Context) (cfg *config.Config, ok bool)

FromContextConfig returns a config object from a context

func FromContextHTTPClient

func FromContextHTTPClient(ctx context.Context) (client *http.Client, ok bool)

FromContextHTTPClient returns an *http.Client object from a context

func FromContextNodeInfo

func FromContextNodeInfo(ctx context.Context) (nodeInfo nodeutil.NodeInfo, ok bool)

FromContextNodeInfo returns a nodeInfo object from a context.

func FromContextToken

func FromContextToken(ctx context.Context) (string, bool)

FromContextToken returns a token string from a context if available.

func GetAuthFromRequest

func GetAuthFromRequest(r *http.Request) (string, error)

GetAuthFromRequest will try to extract JWT from Authorization header.

func WithConfigContext

func WithConfigContext(ctx context.Context, cfg *config.Config) context.Context

WithConfigContext wraps a config object into context.

func WithHTTPClientContext

func WithHTTPClientContext(ctx context.Context, client *http.Client) context.Context

WithHTTPClientContext wraps a *http.Client object into context.

func WithNodeInfoContext

func WithNodeInfoContext(ctx context.Context, nodeInfo nodeutil.NodeInfo) context.Context

WithNodeInfoContext wraps the NodeInfo object into context.

func Wrapped

func Wrapped(next http.Handler, cfg *config.Config, client *http.Client, nodeInfo nodeutil.NodeInfo) http.Handler

Wrapped wraps an http handler with values in a context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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