providers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: MIT Imports: 10 Imported by: 0

README

providers

import "github.com/wyattjoh/ims/internal/platform/providers"

Overview

Index

Package files

middleware.go providers.go

Constants

const ContextKey keyValue = 1

ContextKey is the key for the provider.Provider value in the context.

func GetRemoteBackendProvider

func GetRemoteBackendProvider(ctx context.Context, origin, originCache string) (provider.Provider, error)

GetRemoteBackendProvider will get the backend provider based on the scheme of the url.

func GetRemoteProviderClient

func GetRemoteProviderClient(ctx context.Context, originURL *url.URL, transport http.RoundTripper) (provider.Provider, error)

GetRemoteProviderClient gets the remote provider client or errors.

func GetUnderlyingTransport

func GetUnderlyingTransport(ctx context.Context, originURL *url.URL) (http.RoundTripper, error)

GetUnderlyingTransport checks the url as some clients have specific requirements of the underlying transport.

func Middleware

func Middleware(providers map[string]provider.Provider, next http.HandlerFunc) http.HandlerFunc

Middleware attaches the correct provider.Provider to the request so that the next handler can use it.

func New

func New(ctx context.Context, defaultHost string, backends []string, originCache string) (map[string]provider.Provider, error)

New loops over the origins provided, parsing with the specified providers, and returns the providers keyed by host and optionally wrapped with an origin cache. This will error if the same backend host is extracted more than once.

func ParseBackend

func ParseBackend(defaultHost, backend string) (string, string, error)

ParseBackend parses the backend using the following formats:

<host>,<origin> OR <origin>

Where if the host is not specified, it falls back to the defaultHost.

func WrapCacheRoundTripper

func WrapCacheRoundTripper(ctx context.Context, underlyingTransport http.RoundTripper, originCache string) (http.RoundTripper, error)

WrapCacheRoundTripper gets the roundtripper if the provider is a remote backend type.


Generated by godoc2md

Documentation

Index

Constants

View Source
const ContextKey keyValue = 1

ContextKey is the key for the provider.Provider value in the context.

Variables

This section is empty.

Functions

func GetRemoteBackendProvider

func GetRemoteBackendProvider(ctx context.Context, origin, originCache string) (provider.Provider, error)

GetRemoteBackendProvider will get the backend provider based on the scheme of the url.

func GetRemoteProviderClient

func GetRemoteProviderClient(ctx context.Context, originURL *url.URL, transport http.RoundTripper) (provider.Provider, error)

GetRemoteProviderClient gets the remote provider client or errors.

func GetUnderlyingTransport

func GetUnderlyingTransport(ctx context.Context, originURL *url.URL) (http.RoundTripper, error)

GetUnderlyingTransport checks the url as some clients have specific requirements of the underlying transport.

func Middleware

func Middleware(providers map[string]provider.Provider, next http.HandlerFunc) http.HandlerFunc

Middleware attaches the correct provider.Provider to the request so that the next handler can use it.

func New

func New(ctx context.Context, defaultHost string, backends []string, originCache string) (map[string]provider.Provider, error)

New loops over the origins provided, parsing with the specified providers, and returns the providers keyed by host and optionally wrapped with an origin cache. This will error if the same backend host is extracted more than once.

func ParseBackend

func ParseBackend(defaultHost, backend string) (string, string, error)

ParseBackend parses the backend using the following formats:

<host>,<origin> OR <origin>

Where if the host is not specified, it falls back to the defaultHost.

func WrapCacheRoundTripper

func WrapCacheRoundTripper(ctx context.Context, underlyingTransport http.RoundTripper, originCache string) (http.RoundTripper, error)

WrapCacheRoundTripper gets the roundtripper if the provider is a remote backend type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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