mux

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientErrorMessage    = muxInternal.ClientErrorMessage
	ServerErrorMessage    = muxInternal.ServerErrorMessage
	ResponseServedMessage = muxInternal.ResponseServedMessage
)

The messages the mux logs an error response under, for a log handler that reads the HTTP context to match against rather than write out a second time; see the internal package for what they are for.

Variables

View Source
var MuxHttpContextContextKey muxHttpContextContextType

Functions

This section is empty.

Types

type Mux

type Mux struct {
	EndpointMap map[string]map[string]*endpointPkg.Endpoint
	// contains filtered or unexported fields
}

func New

func New(endpoints ...*endpointPkg.Endpoint) *Mux

func (*Mux) Add

func (mux *Mux) Add(endpoints ...*endpointPkg.Endpoint)

func (*Mux) Delete

func (mux *Mux) Delete(endpoints ...*endpointPkg.Endpoint)

func (*Mux) DuplicateEndpointSpecification

func (mux *Mux) DuplicateEndpointSpecification(endpoint *endpointPkg.Endpoint, routes ...string) error

func (*Mux) Get

func (mux *Mux) Get(path string, method string) *endpointPkg.Endpoint

func (*Mux) GetContentSecurityPolicy

func (mux *Mux) GetContentSecurityPolicy() (*content_security_policy.ContentSecurityPolicy, error)

func (*Mux) GetDocumentEndpointSpecifications

func (mux *Mux) GetDocumentEndpointSpecifications() []*endpointPkg.Endpoint

func (*Mux) ServeHTTP

func (mux *Mux) ServeHTTP(originalResponseWriter http.ResponseWriter, request *http.Request)

func (*Mux) ServeHttpWithCallback

func (bm *Mux) ServeHttpWithCallback(
	originalResponseWriter http.ResponseWriter,
	request *http.Request,
	callback func(*http.Request, *muxTypesResponseWriter.ResponseWriter) (*muxTypesResponse.Response, *muxTypesResponseError.ResponseError),
)

func (*Mux) SetContentSecurityPolicy

func (mux *Mux) SetContentSecurityPolicy(csp *content_security_policy.ContentSecurityPolicy) error

type VhostMux

type VhostMux struct {
	HostToSpecification map[string]*VhostMuxSpecification
	// TrustForwardedHost makes the host looked up below the one the forwarded
	// headers name, rather than the one on the request. It is for a service
	// behind a proxy that rewrites Host to an address of its own -- Firebase
	// Hosting rewriting to a run.app URL, say -- where without it every request
	// arrives for a host this mux does not answer for and is refused.
	//
	// It is off by default, and turning it on is a decision about what can
	// reach the service rather than about what is in front of it: the headers
	// are the client's to write unless a proxy overwrites them AND nothing can
	// reach the service except through that proxy. Where the second does not
	// hold, the 421 below stops being a check and becomes routing.
	TrustForwardedHost bool
	// contains filtered or unexported fields
}

func (*VhostMux) PatchHttpServer

func (vhostMux *VhostMux) PatchHttpServer(httpServer *http.Server)

func (*VhostMux) ServeHTTP

func (vhostMux *VhostMux) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)

func (*VhostMux) ServeHttpWithCallback

func (bm *VhostMux) ServeHttpWithCallback(
	originalResponseWriter http.ResponseWriter,
	request *http.Request,
	callback func(*http.Request, *muxTypesResponseWriter.ResponseWriter) (*muxTypesResponse.Response, *muxTypesResponseError.ResponseError),
)

type VhostMuxSpecification

type VhostMuxSpecification struct {
	Mux         http.Handler
	RedirectTo  string
	Certificate *tls.Certificate
}

Directories

Path Synopsis
mux
types
forwarded_headers
Package forwarded_headers reads what the proxies in front of a service say about the request the client actually made: RFC 7239's `Forwarded`, and the older `X-Forwarded-*` headers it replaced.
Package forwarded_headers reads what the proxies in front of a service say about the request the client actually made: RFC 7239's `Forwarded`, and the older `X-Forwarded-*` headers it replaced.

Jump to

Keyboard shortcuts

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