mux

package
v0.0.0-...-57974ef Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Overview

Implements the HTTP routing strategy used by the amppkg server. The main purpose for rolling our own is to be able to route the following types of URLs:

/priv/doc/https://example.com/esc%61ped%2Furl.html

and have the signer sign the URL exactly as it is encoded in the request, in order to meet docs/cache_requirements.md.

The default http mux had some problems which led to me investigating 3rd party routers. (TODO(twifkak): Remember and document those problems.)

I investigated two 3rd party routers capable of handling catch-all suffix parameters:

https://github.com/julienschmidt/httprouter
https://github.com/dimfeld/httptreemux

Both libs unescape their catch-all parameters, making the above use-case impossible. The latter does so despite documenting support for unmodified URL escapings. This, plus a lack of feature needs, led me to believe that writing our own mux was the best approach.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(certCache http.Handler, signer http.Handler, validityMap http.Handler, healthz http.Handler, metrics http.Handler) http.Handler

New is the main entry point. Use the return value for http.Server.Handler.

func Params

func Params(req *http.Request) map[string]string

Params gets the params from the request context, injected by the mux. Guaranteed to be non-nil. Call from the handlers.

func WithParams

func WithParams(req *http.Request, params map[string]string) *http.Request

WithParams returns a copy of req annotated with the given params. (Params is stored by reference, and so may be mutated afterwards.) To be called only by this library itself or by tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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