MCPcopy Create free account

hub / github.com/go-chi/chi / functions

Functions435 in github.com/go-chi/chi

↓ 2 callersFunctionlongestPrefix
longestPrefix finds the length of the shared prefix of two strings
tree.go:822
↓ 2 callersMethodmaybeWriteHeader
()
middleware/wrap_writer.go:116
↓ 2 callersMethodnextRoutePath
(rctx *Context)
mux.go:493
↓ 2 callersFunctionprintPrettyStack
printPrettyStack prints a formatted stack trace to stderr. When useColor is false, ANSI colour codes are suppressed, which is useful for terminals tha
middleware/recoverer.go:61
↓ 2 callersFunctionreplaceWildcards
replaceWildcards takes a route pattern and replaces all occurrences of "/*/" with "/". It iteratively runs until no wildcards remain to correctly hand
context.go:139
↓ 2 callersMethodroutes
()
tree.go:633
↓ 2 callersFunctionsplit
Split a string in two parts, cleaning any whitespace.
middleware/content_charset.go:37
↓ 2 callersFunctiontestRequestWithAcceptedEncodings
(t *testing.T, ts *httptest.Server, method, path string, encodings ...string)
middleware/compress_test.go:206
↓ 2 callersMethodupdateRouteHandler
updateRouteHandler builds the single mux handler that is a chain of the middleware stack, as defined by calls to Use(), and the tree router (Mux) itse
mux.go:517
↓ 2 callersMethodupdateSubRoutes
Recursively update data on child routers.
mux.go:503
↓ 1 callersFunctionAllowContentEncoding
AllowContentEncoding enforces a whitelist of request Content-Encoding otherwise responds with a 415 Unsupported Media Type status.
middleware/content_encoding.go:10
↓ 1 callersFunctionAllowContentType
AllowContentType enforces a whitelist of request Content-Types otherwise responds with a 415 Unsupported Media Type status.
middleware/content_type.go:20
↓ 1 callersFunctionCompress
Compress is a middleware that compresses response body of a given content types to a data format based on Accept-Encoding request header. It uses a gi
middleware/compress.go:45
↓ 1 callersFunctionContentCharset
ContentCharset generates a handler that writes a 415 Unsupported Media Type response if none of the charsets match. An empty charset will allow reques
middleware/content_charset.go:11
↓ 1 callersMethodDiscard
Discard causes all writes to the original ResponseWriter be discarded, instead writing only to the tee'd writer if it's set. The caller is responsible
middleware/wrap_writer.go:68
↓ 1 callersMethodDiscard
()
middleware/wrap_writer.go:138
↓ 1 callersFunctionFileServer
FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem.
_examples/fileserver/main.go:48
↓ 1 callersMethodFind
Find searches the routing tree for the pattern that matches the method/path. Note: the *Context state is updated during execution, so manage the stat
mux.go:374
↓ 1 callersMethodFlush
()
middleware/wrap_writer.go:194
↓ 1 callersMethodFlush
()
middleware/wrap_writer.go:239
↓ 1 callersMethodGet
Get adds the route `pattern` that matches a GET http method to execute the `handlerFn` http.HandlerFunc.
mux.go:155
↓ 1 callersFunctionGetLogEntry
GetLogEntry returns the in-context LogEntry for a request.
middleware/logger.go:75
↓ 1 callersMethodGroup
Group creates a new inline-Mux with a copy of middleware stack. It's useful for a group of handlers along the same routing path that use an additional
mux.go:268
↓ 1 callersMethodHandle
Handle adds the route `pattern` that matches any http method to execute the `handler` http.Handler.
mux.go:109
↓ 1 callersMethodIsMatch
(value string)
middleware/route_headers.go:116
↓ 1 callersMethodMatch
(v string)
middleware/route_headers.go:141
↓ 1 callersMethodMethodNotAllowedHandler
MethodNotAllowedHandler returns the default Mux 405 responder whenever a method cannot be resolved for a route.
mux.go:413
↓ 1 callersMethodMiddlewares
Middlewares returns the list of middlewares in use by the router.
chi.go:124
↓ 1 callersMethodNewLogEntry
(r *http.Request)
middleware/logger.go:64
↓ 1 callersFunctionNewUserPayloadResponse
(user *User)
_examples/rest/main.go:295
↓ 1 callersMethodPanic
(v interface{}, stack []byte)
middleware/logger.go:71
↓ 1 callersMethodPost
Post adds the route `pattern` that matches a POST http method to execute the `handlerFn` http.HandlerFunc.
mux.go:179
↓ 1 callersFunctionPrintPrettyStack
(rvr interface{})
middleware/recoverer.go:54
↓ 1 callersFunctionRedirectSlashes
RedirectSlashes is a middleware that will match request paths with a trailing slash and redirect to the same path, less the trailing slash. NOTE: Red
middleware/strip.go:41
↓ 1 callersFunctionRegisterMethod
RegisterMethod adds support for custom HTTP method handlers, available via Router#Method and Router#MethodFunc
tree.go:70
↓ 1 callersMethodRender
(w http.ResponseWriter, r *http.Request)
_examples/versions/presenter/v2/article.go:23
↓ 1 callersMethodRouteAny
(header string, match []string, middlewareHandler func(next http.Handler) http.Handler)
middleware/route_headers.go:58
↓ 1 callersMethodRouteDefault
(handler func(next http.Handler) http.Handler)
middleware/route_headers.go:72
↓ 1 callersFunctionRouteHeaders
RouteHeaders is a neat little header-based router that allows you to direct the flow of a request through a middleware stack based on a request header
middleware/route_headers.go:42
↓ 1 callersMethodSort
Sort the list of nodes by label
tree.go:834
↓ 1 callersFunctionStripPrefix
StripPrefix is a middleware that will strip the provided prefix from the request path before handing the request over to the next handler.
middleware/strip.go:73
↓ 1 callersFunctionStripSlashes
StripSlashes is a middleware that will match request paths with a trailing slash, strip it from the path and continue routing through the mux, if a ro
middleware/strip.go:14
↓ 1 callersFunctionSunset
Sunset set Deprecation/Sunset header to response This can be used to enable Sunset in a route or a route group For more: https://www.rfc-editor.org/rf
middleware/sunset.go:11
↓ 1 callersMethodSwap
(i, j int)
tree.go:836
↓ 1 callersMethodTee
Tee causes the response body to be written to the given io.Writer in addition to proxying the writes through. Only one io.Writer can be tee'd to at on
middleware/wrap_writer.go:61
↓ 1 callersFunctionThrottle
Throttle is a middleware that limits number of currently processed requests at a time across all users. Note: Throttle is not a rate-limiter per user,
middleware/throttle.go:32
↓ 1 callersFunctionTimeout
Timeout is a middleware that cancels ctx after a given timeout and return a 504 Gateway Timeout error to the client. It's required that you select th
middleware/timeout.go:32
↓ 1 callersFunctionURLParamFromCtx
URLParamFromCtx returns the url parameter from a http.Request Context.
context.go:18
↓ 1 callersFunctionWithLogEntry
WithLogEntry sets the in-context LogEntry for a request.
middleware/logger.go:81
↓ 1 callersMethodWriteHeader
(code int)
middleware/compress.go:302
↓ 1 callersMethodaddChild
addChild appends the new `child` node to the tree using the `pattern` as the trie key. For a URL router like chi's, we split the static, param, regexp
tree.go:244
↓ 1 callersFunctionadminRouter
A completely separate router for administrator routes
_examples/rest/main.go:219
↓ 1 callersFunctionapiVersionCtx
(version string)
_examples/versions/main.go:51
↓ 1 callersFunctionarticleRouter
()
_examples/versions/main.go:60
↓ 1 callersFunctionassertError
(t *testing.T, err error)
middleware/middleware_test.go:142
↓ 1 callersFunctionbasicAuthFailed
(w http.ResponseWriter, realm string)
middleware/basic_auth.go:30
↓ 1 callersFunctiondbGetArticle
(id string)
_examples/rest/main.go:475
↓ 1 callersFunctiondbGetArticleBySlug
(slug string)
_examples/rest/main.go:484
↓ 1 callersFunctiondbGetUser
(id int64)
_examples/rest/main.go:513
↓ 1 callersFunctiondbNewArticle
(article *Article)
_examples/rest/main.go:469
↓ 1 callersFunctiondbRemoveArticle
(id string)
_examples/rest/main.go:503
↓ 1 callersFunctiondbUpdateArticle
(id string, article *Article)
_examples/rest/main.go:493
↓ 1 callersFunctiondecodeResponseBody
(t *testing.T, resp *http.Response)
middleware/compress_test.go:229
↓ 1 callersMethoddecorateFuncCallLine
(line string, useColor bool, num int)
middleware/recoverer.go:132
↓ 1 callersMethoddecorateLine
(line string, useColor bool, num int)
middleware/recoverer.go:118
↓ 1 callersMethoddecorateSourceLine
(line string, useColor bool, num int)
middleware/recoverer.go:172
↓ 1 callersFunctionequalHandlers
equalHandlers reports whether a and b are the same handler value. Handlers are commonly funcs (e.g. http.HandlerFunc), and a direct == on those panics
tree.go:696
↓ 1 callersMethodfindRoute
Recursive edge traversal by checking all nodeTyp groups along the way. It's like searching through a multi-dimensional radix trie.
tree.go:410
↓ 1 callersMethodgetEdge
(ntyp nodeTyp, label, tail byte, prefix string)
tree.go:340
↓ 1 callersFunctioninAnyPrefix
inAnyPrefix reports whether ip falls within any of the given prefixes.
middleware/client_ip.go:250
↓ 1 callersMethodisCompressible
()
middleware/compress.go:286
↓ 1 callersFunctionmaintainDefaultRequestID
()
middleware/request_id_test.go:12
↓ 1 callersFunctionmatchAcceptEncoding
(accepted []string, encoding string)
middleware/compress.go:252
↓ 1 callersFunctionmethodNotAllowedHandler
methodNotAllowedHandler is a helper function to respond with a 405, method not allowed. It sets the Allow header with the list of allowed methods for
mux.go:524
↓ 1 callersMethodparse
(debugStack []byte, rvr interface{}, useColor bool)
middleware/recoverer.go:76
↓ 1 callersFunctionpatParamKeys
(pattern string)
tree.go:803
↓ 1 callersFunctionrealIP
(r *http.Request)
middleware/realip.go:39
↓ 1 callersMethodreplaceChild
(label, tail byte, child *node)
tree.go:328
↓ 1 callersFunctionrunChain
runChain is like run but applies multiple middlewares in order.
middleware/client_ip_test.go:722
↓ 1 callersMethodselectEncoder
selectEncoder returns the encoder, the name of the encoder, and a closer function.
middleware/compress.go:223
↓ 1 callersFunctionservice
()
_examples/graceful/main.go:45
↓ 1 callersMethodsetEndpoint
(method methodTyp, handler http.Handler, pattern string)
tree.go:353
↓ 1 callersMethodsetRetryAfterHeaderIfNeeded
setRetryAfterHeaderIfNeeded sets Retry-After HTTP header if corresponding retryAfterFn option of throttler is initialized.
middleware/throttle.go:146
↓ 1 callersMethodtailSort
tailSort pushes nodes with '/' as the tail to the end of the list for param nodes. The list order determines the traversal order.
tree.go:841
↓ 1 callersFunctiontestHandler
(t *testing.T, h http.Handler, method, path string, body io.Reader)
mux_test.go:2061
↓ 1 callersFunctiontestRequestNoRedirect
(t *testing.T, ts *httptest.Server, method, path string, body io.Reader)
middleware/middleware_test.go:105
↓ 1 callersFunctionwalk
(r Routes, walkFn WalkFunc, parentRoute string, parentMw ...func(http.Handler) http.Handler)
tree.go:886
↓ 1 callersMethodwalk
(fn func(eps endpoints, subroutes Routes) bool)
tree.go:716
FunctionAdminOnly
AdminOnly middleware restricts access to just administrators.
_examples/rest/main.go:235
FunctionArticleCtx
ArticleCtx middleware is used to load an Article object from the URL parameters passed through as the request. In case the Article could not be found,
_examples/rest/main.go:124
FunctionBasicAuth
BasicAuth implements a simple middleware handler for adding basic http auth to a route.
middleware/basic_auth.go:10
FunctionBenchmarkMux
(b *testing.B)
mux_test.go:2076
FunctionBenchmarkThrottle
(b *testing.B)
middleware/throttle_test.go:315
FunctionBenchmarkTreeGet
(b *testing.B)
tree_test.go:489
FunctionBenchmarkWalkXFF
BenchmarkWalkXFF measures the cost of walking a merged X-Forwarded-For chain end-to-end (visitor never stops). Exercises the worst case for ClientIPFr
middleware/client_ip_bench_test.go:18
FunctionBenchmarkWalkXFF_RightmostStop
BenchmarkWalkXFF_RightmostStop measures the common case for both ClientIPFromXFF (no trusted prefixes => stop at the first / rightmost entry) and Clie
middleware/client_ip_bench_test.go:41
MethodBind
(r *http.Request)
_examples/rest/main.go:327
FunctionCleanPath
CleanPath middleware will clean out double slash mistakes from a user's request path. For example, if a user requests /users//1 or //users////1 will b
middleware/clean_path.go:12
FunctionClientIPFromRemoteAddr
ClientIPFromRemoteAddr stores the client IP read from the TCP RemoteAddr of the incoming request — the IP address of whoever opened the connection to
middleware/client_ip.go:187
MethodConnect
Connect adds the route `pattern` that matches a CONNECT http method to execute the `handlerFn` http.HandlerFunc.
mux.go:143
← previousnext →101–200 of 435, ranked by callers