mux

package
v0.0.0-...-052274c Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder allows the construction of an http.Handler that is able to route based on path and host.

func Create

func Create() *Builder

Create constructs a new empty Builder.

func (*Builder) Build

func (b *Builder) Build() *Serve

Build constructs an http.Handler that can be used for serving requests. Note that the Builder can no longer be used after Build is called.

func (*Builder) ForAnyHost

func (b *Builder) ForAnyHost() *PathMux

ForAnyHost gets the PathMux that matches a request to any host.

func (*Builder) ForHost

func (b *Builder) ForHost(host string) *PathMux

ForHost creates or gets the PathMux associated with a given host. Note that any ports are stripped from the host so that localhost and localhost:8080 are equivalent entries.

type PathMux

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

PathMux is a mux that routes only on request path.

func (*PathMux) Handle

func (m *PathMux) Handle(path string, h http.Handler) *PathMux

Handle associates a new handler to a path. Paths are matched consistent with net.ServeMux in the go standard library, except that host routes are not supported.

func (*PathMux) HandleFunc

func (m *PathMux) HandleFunc(path string, h func(w http.ResponseWriter, r *http.Request)) *PathMux

HandleFunc is identical to Handle but accepts a function instead of a Handler.

type Serve

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

Serve ...

func (*Serve) ServeHTTP

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

Jump to

Keyboard shortcuts

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