MCPcopy
hub / github.com/go-chi/chi / Router

Interface Router

chi.go:66–114  ·  chi.go::Router

Router consisting of the core routing methods used by chi's Mux, using only the standard net/http.

Source from the content-addressed store, hash-verified

64// Router consisting of the core routing methods used by chi's Mux,
65// using only the standard net/http.
66type Router interface {
67 http.Handler
68 Routes
69
70 // Use appends one or more middlewares onto the Router stack.
71 Use(middlewares ...func(http.Handler) http.Handler)
72
73 // With adds inline middlewares for an endpoint handler.
74 With(middlewares ...func(http.Handler) http.Handler) Router
75
76 // Group adds a new inline-Router along the current routing
77 // path, with a fresh middleware stack for the inline-Router.
78 Group(fn func(r Router)) Router
79
80 // Route mounts a sub-Router along a `pattern` string.
81 Route(pattern string, fn func(r Router)) Router
82
83 // Mount attaches another http.Handler along ./pattern/*
84 Mount(pattern string, h http.Handler)
85
86 // Handle and HandleFunc adds routes for `pattern` that matches
87 // all HTTP methods.
88 Handle(pattern string, h http.Handler)
89 HandleFunc(pattern string, h http.HandlerFunc)
90
91 // Method and MethodFunc adds routes for `pattern` that matches
92 // the `method` HTTP method.
93 Method(method, pattern string, h http.Handler)
94 MethodFunc(method, pattern string, h http.HandlerFunc)
95
96 // HTTP-method routing along `pattern`
97 Connect(pattern string, h http.HandlerFunc)
98 Delete(pattern string, h http.HandlerFunc)
99 Get(pattern string, h http.HandlerFunc)
100 Head(pattern string, h http.HandlerFunc)
101 Options(pattern string, h http.HandlerFunc)
102 Patch(pattern string, h http.HandlerFunc)
103 Post(pattern string, h http.HandlerFunc)
104 Put(pattern string, h http.HandlerFunc)
105 Trace(pattern string, h http.HandlerFunc)
106
107 // NotFound defines a handler to respond whenever a route could
108 // not be found.
109 NotFound(h http.HandlerFunc)
110
111 // MethodNotAllowed defines a handler to respond whenever a method is
112 // not allowed.
113 MethodNotAllowed(h http.HandlerFunc)
114}
115
116// Routes interface adds two methods for router traversal, which is also
117// used by the `docgen` subpackage to generation documentation for Routers.

Callers 93

TestMuxBasicFunction · 0.95
TestMuxNestedNotFoundFunction · 0.95
TestMuxMiddlewareStackFunction · 0.95
TestMuxRouteGroupsFunction · 0.95
TestNestedGroupsFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
TestMuxNestedNotFoundFunction · 0.95
TestMuxWithFunction · 0.95
TestRouterFromMuxWithFunction · 0.95

Implementers 1

Muxmux.go

Calls

no outgoing calls

Tested by

no test coverage detected