Back to godoc.org
mellium.im/verbmux

package verbmux

v0.0.3
Latest Go to latest
Published: Mar 31, 2020 | License: BSD-2-Clause | Module: mellium.im/verbmux

Overview

Package verbmux provides functionality for a simple HTTP multiplexer that routes requests based on the HTTP verb (GET, POST, CONNECT, etc.). It can handle OPTIONS requests automatically.

Index

func New

func New(v ...Verb) http.Handler

New constructs a new multiplexer that responds to requests with the provided verb's. OPTIONS requests are automatically handled unless they are overridden.

type Verb

type Verb func(vm verbMux)

Verb represents an HTTP verb such as GET or PUT. Verbs should not be created manually, instead use Custom or one of the existing verb functions.

func Custom

func Custom(verb string, handler http.Handler) Verb

Custom handles custom HTTP verbs, for example, if you wanted to handle the WebDAV LOCK or UNLOCK verbs.

func Delete

func Delete(handler http.Handler) Verb

Delete handles HTTP DELETE requests.

func Get

func Get(handler http.Handler) Verb

Get handles HTTP GET requests.

func Options

func Options(handler http.Handler) Verb

Options handles HTTP OPTIONS requests. A new verb muxer handles OPTIONS requests by default, so an Options verb only needs to be specified if custom behavior is desired, or OPTIONS requests should not be handled (by passing a nil handler).

func Post

func Post(handler http.Handler) Verb

Post handles HTTP POST requests.

func Put

func Put(handler http.Handler) Verb

Put handles HTTP PUT requests.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier