handlers

package
Version: v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package handlers provides several non-proxy handlers for use internally by other Trickster handlers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigHandleFunc

func ConfigHandleFunc(conf *config.Config) func(http.ResponseWriter, *http.Request)

ConfigHandleFunc responds to the HTTP request with the running configuration

func HandleBadRequestResponse

func HandleBadRequestResponse(w http.ResponseWriter, r *http.Request)

HandleBadRequestResponse responds to an HTTP Request with 400 Bad Request

func HandleLocalResponse

func HandleLocalResponse(w http.ResponseWriter, r *http.Request)

HandleLocalResponse responds to an HTTP Request based on the local configuration without making any upstream requests

func HandleRedirectResponse

func HandleRedirectResponse(w http.ResponseWriter, r *http.Request)

HandleRedirectResponse responds to an HTTP Request with a 302 Redirect with 30x code and Location header inserted into the context by a previous handler Requires redirectCode and redirectLocation have been set

func PingHandleFunc

func PingHandleFunc(conf *config.Config) func(http.ResponseWriter, *http.Request)

PingHandleFunc responds to an HTTP Request with 200 OK and "pong"

func ReloadHandleFunc

func ReloadHandleFunc(f reload.ReloaderFunc, conf *config.Config, wg *sync.WaitGroup,
	log *tl.Logger, caches map[string]cache.Cache,
	args []string) func(http.ResponseWriter, *http.Request)

ReloadHandleFunc will reload the running configuration if it has changed

func WithRedirects

func WithRedirects(ctx context.Context, rc int, rl string) context.Context

WithRedirects will attach the configured redirect code and location information to the provided Context

Types

type SwitchHandler

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

SwitchHandler is an HTTP Wrapper that allows users to update the underlying handler in-place once associated with a net.Listener

func NewSwitchHandler

func NewSwitchHandler(router http.Handler) *SwitchHandler

NewSwitchHandler returns a New *SwitchHandler

func (*SwitchHandler) Handler

func (s *SwitchHandler) Handler() http.Handler

Handler returns the current mux

func (*SwitchHandler) ServeHTTP

func (s *SwitchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves an HTTP Request

func (*SwitchHandler) Update

func (s *SwitchHandler) Update(h http.Handler)

Update atomically changes the underlying handler without impacting user requests or uptime

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to