mux

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 8

Documentation

Overview

Package mux provides some basic implementations for building routers based on net/http mux

Index

Constants

View Source
const DefaultDebugPattern = "/__debug/"
View Source
const NEGOTIATE = "negotiate"

Variables

Functions

func DebugHandler

func DebugHandler(logger log.Logger) http.HandlerFunc

func DefaultEngine

func DefaultEngine() *engine

func DefaultFactory

func DefaultFactory(pf proxy.Factory, logger log.Logger) route.Factory

func HealthHandler

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

func NewFactory

func NewFactory(cfg Config) route.Factory

func NoopParamExtractor

func NoopParamExtractor(_ *http.Request) map[string]string

func RegisterRender

func RegisterRender(name string, r Render)

Types

type Config

type Config struct {
	Engine         Engine
	Middlewares    []HandlerMiddleware
	HandlerFactory HandlerFactory
	ProxyFactory   proxy.Factory
	Logger         log.Logger
	DebugPattern   string
	RunServer      RunServerFunc
}

type Engine

type Engine interface {
	http.Handler
	Handle(pattern, method string, handler http.Handler)
}

type HTTPErrorInterceptor

type HTTPErrorInterceptor struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewHTTPErrorInterceptor

func NewHTTPErrorInterceptor(w http.ResponseWriter) *HTTPErrorInterceptor

func (*HTTPErrorInterceptor) WriteHeader

func (i *HTTPErrorInterceptor) WriteHeader(code int)

type HandlerFactory

type HandlerFactory func(*config.EndpointConfig, proxy.Proxy) http.HandlerFunc

func CustomEndpointHandler

func CustomEndpointHandler(rb RequestBuilder) HandlerFactory

func CustomEndpointHandlerWithHTTPError

func CustomEndpointHandlerWithHTTPError(rb RequestBuilder, errF server.ToHTTPError) HandlerFactory

type HandlerMiddleware

type HandlerMiddleware interface {
	Handler(h http.Handler) http.Handler
}

type ParamExtractor

type ParamExtractor func(r *http.Request) map[string]string

type Render

type Render func(http.ResponseWriter, *proxy.Response)

type RequestBuilder

type RequestBuilder func(r *http.Request, queryString, headersToSend []string) *proxy.Request

func NewRequestBuilder

func NewRequestBuilder(paramExtractor ParamExtractor) RequestBuilder

Jump to

Keyboard shortcuts

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