verbmux

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: BSD-2-Clause Imports: 2 Imported by: 0

README

verbmux

Issue Tracker GoDoc Chat License

Buy Me A Coffee Support Me

verbmux is an HTTP multiplexer that can be used to route HTTP requests in Go programs based on their verb (GET, SET, HEAD, etc). It handles OPTIONS requests automatically and is designed to be composable with other HTTP routers.

Use it in your program with:

import (
  "mellium.im/verbmux"
)

Documentation

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

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

Types

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.

Jump to

Keyboard shortcuts

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