webhelp.v1: gopkg.in/webhelp.v1/whroute Index | Files

package whroute

import "gopkg.in/webhelp.v1/whroute"

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

Index

Package Files

routes.go

Constants

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 = "[/<*>]"
)

func HandlerFunc Uses

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 Uses

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 Uses

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 Uses

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.

Package whroute imports 4 packages (graph) and is imported by 14 packages. Updated 2017-06-03. Refresh now. Tools for package owners.