Version: v1.0.0-...-3f30213 Latest Latest

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 4 Imported by: 27



Package whroute provides utilities to implement route listing, whereby http.Handlers that opt in can list what routes they understand.



View Source
const (
	// AllMethods should be returned from a whroute.Lister when all methods are
	// successfully handled.
	AllMethods = "ALL"

	// AllPaths should be returned from a whroute.Lister when all paths are
	// successfully handled.
	AllPaths = "[/<*>]"


This section is empty.


func HandlerFunc

func HandlerFunc(routes http.Handler,
	fn func(http.ResponseWriter, *http.Request)) http.Handler

HandlerFunc advertises the routes from routes, but serves content using fn.

func PrintRoutes

func PrintRoutes(out io.Writer, h http.Handler) (err error)

PrintRoutes will write all routes of h to out, using the Routes method.

func Routes

func Routes(h http.Handler,
	cb func(method, path string, annotations map[string]string))

Routes will call cb with all routes known to h.


type Lister

type Lister interface {
	Routes(cb func(method, path string, annotations map[string]string))

Lister is an interface handlers can implement if they want the Routes method to work. All http.Handlers in the webhelp package implement Routes.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL