MCPcopy Create free account

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

Functions435 in github.com/go-chi/chi

MethodConnect
HTTP-method routing along `pattern`
chi.go:97
MethodCreate
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:34
MethodCreate
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:35
FunctionCreateArticle
CreateArticle persists the posted Article and returns it back to the client as an acknowledgement.
_examples/rest/main.go:155
MethodDelete
Delete adds the route `pattern` that matches a DELETE http method to execute the `handlerFn` http.HandlerFunc.
mux.go:149
MethodDelete
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:46
MethodDelete
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:47
FunctionDeleteArticle
DeleteArticle removes an existing Article from our persistent store.
_examples/rest/main.go:201
FunctionExample_clientIP
Example_clientIP shows how to choose a ClientIPFrom* middleware. There is no safe default — pick exactly ONE based on your network setup: - [middlewa
middleware/client_ip_example_test.go:40
FunctionExample_clientIPFromXFFTrustedProxies
Example_clientIPFromXFFTrustedProxies shows that with two proxies the client sits at XFF[len-2] and any client-prepended entries to the left of that p
middleware/client_ip_example_test.go:84
MethodFlush
()
middleware/wrap_writer.go:147
MethodFlush
()
middleware/wrap_writer.go:172
MethodFlush
()
middleware/compress.go:349
MethodGet
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:38
MethodGet
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:39
FunctionGetArticle
GetArticle returns the specific Article. You'll notice it just fetches the Article right off the context, as its understood that if we made it this fa
_examples/rest/main.go:173
FunctionGetHead
GetHead automatically route undefined HEAD requests to GET handlers.
middleware/get_head.go:10
MethodHandleFunc
HandleFunc adds the route `pattern` that matches any http method to execute the `handlerFn` http.HandlerFunc.
mux.go:121
MethodHandler
(next http.Handler)
middleware/route_headers.go:77
MethodHead
Head adds the route `pattern` that matches a HEAD http method to execute the `handlerFn` http.HandlerFunc.
mux.go:161
FunctionHeartbeat
Heartbeat endpoint middleware useful to setting up a path like `/ping` that load balancers or uptime testing external services can make a request befo
middleware/heartbeat.go:12
MethodHijack
()
middleware/wrap_writer.go:178
MethodHijack
()
middleware/wrap_writer.go:200
MethodHijack
()
middleware/logger_test.go:17
MethodHijack
()
middleware/compress.go:365
MethodLess
(i, j int)
tree.go:837
MethodList
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:30
MethodList
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:31
FunctionListArticles
(w http.ResponseWriter, r *http.Request)
_examples/rest/main.go:114
FunctionLogger
Logger is a middleware that logs the start and end of each request, along with some useful data about what was requested, what the response status was
middleware/logger.go:39
MethodMatch
Match searches the routing tree for a handler that matches the method/path. It's similar to routing a http request, but without executing the handler
mux.go:365
FunctionMaybe
Maybe middleware will allow you to change the flow of the middleware stack execution depending on return value of maybeFn(request). This is useful for
middleware/maybe.go:8
MethodMethodFunc
MethodFunc adds the route `pattern` that matches `method` http method to execute the `handlerFn` http.HandlerFunc.
mux.go:137
MethodMethodNotAllowed
MethodNotAllowed sets a custom http.HandlerFunc for routing paths where the method is unresolved. The default handler returns a 405 with an empty body
mux.go:223
MethodMiddlewares
Middlewares returns a slice of middleware handler functions.
mux.go:355
FunctionNew
New will create a new middleware handler from a http.Handler.
middleware/middleware.go:6
MethodNewLogEntry
NewLogEntry creates a new LogEntry for the request.
middleware/logger.go:98
FunctionNextRequestID
NextRequestID generates the next request ID in the sequence.
middleware/request_id.go:94
FunctionNoCache
NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router (or subrouter) from being cached by an upstream proxy a
middleware/nocache.go:40
MethodNotFound
NotFound sets a custom http.HandlerFunc for routing paths that could not be found. The default 404 handler is `http.NotFound`.
mux.go:203
MethodOptions
Options adds the route `pattern` that matches an OPTIONS http method to execute the `handlerFn` http.HandlerFunc.
mux.go:167
MethodOptions
(pattern string, h http.HandlerFunc)
chi.go:101
FunctionPageRoute
PageRoute is a simple middleware which allows you to route a static GET request at the middleware stack level.
middleware/page_route.go:10
MethodPanic
(v interface{}, stack []byte)
middleware/logger.go:168
MethodPatch
Patch adds the route `pattern` that matches a PATCH http method to execute the `handlerFn` http.HandlerFunc.
mux.go:173
MethodPatch
(pattern string, h http.HandlerFunc)
chi.go:102
FunctionPathRewrite
PathRewrite is a simple middleware which allows you to rewrite the request URL path.
middleware/path_rewrite.go:9
FunctionPing
Ping returns pong
_examples/router-walk/main.go:40
FunctionPresentError
(r *http.Request, err error)
_examples/versions/data/errors.go:16
MethodPrint
(v ...interface{})
middleware/recoverer_test.go:17
FunctionProfiler
Profiler is a convenient subrouter used for mounting net/http/pprof. ie. func MyService() http.Handler { r := chi.NewRouter() // ..middlewares
middleware/profiler.go:22
MethodPush
(target string, opts *http.PushOptions)
middleware/wrap_writer.go:205
MethodPush
(target string, opts *http.PushOptions)
middleware/compress.go:372
MethodPut
Put adds the route `pattern` that matches a PUT http method to execute the `handlerFn` http.HandlerFunc.
mux.go:185
MethodQuery
Query adds the route `pattern` that matches a QUERY http method to execute the `handlerFn` http.HandlerFunc.
mux.go:191
MethodReadFrom
(src io.Reader)
middleware/wrap_writer_test.go:21
FunctionRealIP
RealIP is a middleware that sets a http.Request's RemoteAddr to the results of parsing either the True-Client-IP, X-Real-IP or the X-Forwarded-For hea
middleware/realip.go:28
FunctionRecoverer
Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possib
middleware/recoverer.go:22
MethodRender
(w http.ResponseWriter, r *http.Request)
_examples/versions/presenter/v3/article.go:25
MethodRender
(w http.ResponseWriter, r *http.Request)
_examples/versions/presenter/v1/article.go:16
MethodRender
(w http.ResponseWriter, r *http.Request)
_examples/rest/main.go:372
MethodRender
(w http.ResponseWriter, r *http.Request)
_examples/rest/main.go:410
FunctionRequestID
RequestID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-00
middleware/request_id.go:67
FunctionRequestSize
RequestSize is a middleware that will limit request sizes to a specified number of bytes. It uses MaxBytesReader to do so.
middleware/request_size.go:9
MethodReset
Reset a routing context to its initial state.
context.go:82
MethodRoute
(header, match string, middlewareHandler func(next http.Handler) http.Handler)
middleware/route_headers.go:48
MethodRoutes
Routes returns a slice of routing information from the tree, useful for traversing available routes of a router.
mux.go:350
MethodRoutes
Routes creates a REST router for the todos resource
_examples/todos-resource/users.go:12
MethodRoutes
Routes creates a REST router for the todos resource
_examples/todos-resource/todos.go:12
FunctionSearchArticles
SearchArticles searches the Articles data for a matching article. It's just a stub, but you get the idea.
_examples/rest/main.go:149
MethodServeHTTP
(w http.ResponseWriter, r *http.Request)
chain.go:30
FunctionSetHeader
SetHeader is a convenience handler to set a response header key/value
middleware/content_type.go:9
MethodStatus
()
middleware/wrap_writer.go:122
MethodString
()
context.go:164
FunctionSupressNotFound
SupressNotFound will quickly respond with a 404 if the route is not found and will not continue to the next middleware handler. This is handy to put
middleware/supress_notfound.go:15
MethodSync
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:51
FunctionTestAdvisory_GHSA_3fxj_6jh8_hvhx
GHSA-3fxj-6jh8-hvhx (Saku0512): an admin endpoint gates on the client IP, and an attacker prepends a spoofed IP to X-Forwarded-For. middleware.RealIP
middleware/client_ip_test.go:364
FunctionTestAdvisory_GHSA_9g5q_2w5x_hmxf
GHSA-9g5q-2w5x-hmxf (convto): RealIP set r.RemoteAddr from the leftmost XFF IP. With ClientIPFromXFF the rightmost-untrusted IP is selected, and we ne
middleware/client_ip_test.go:408
FunctionTestAdvisory_GHSA_rjr7_jggh_pgcp
GHSA-rjr7-jggh-pgcp (rezmoss): RealIP trusted X-Real-IP / True-Client-IP / X-Forwarded-For unconditionally and used the leftmost XFF value, allowing "
middleware/client_ip_test.go:442
FunctionTestBasicWriterDiscardsWritesToOriginalResponseWriter
(t *testing.T)
middleware/wrap_writer_test.go:63
FunctionTestBasicWritesTeesWritesWithoutDiscard
(t *testing.T)
middleware/wrap_writer_test.go:43
FunctionTestClientIPFromHeader
(t *testing.T)
middleware/client_ip_test.go:12
FunctionTestClientIPFromHeader_MultiValueLastWins
TestClientIPFromHeader_MultiValueLastWins is a regression pin for the defense-in-depth gap fixed in a8e3dbf. The pre-fix implementation read the trust
middleware/client_ip_test.go:505
FunctionTestClientIPFromRemoteAddr
(t *testing.T)
middleware/client_ip_test.go:248
FunctionTestClientIPFromRemoteAddr_V4MappedIsUnmapped
TestClientIPFromRemoteAddr_V4MappedIsUnmapped pins the desired normalization for v4 connections accepted on a dual-stack listener: Go's net/http surfa
middleware/client_ip_test.go:617
FunctionTestClientIPFromXFFTrustedProxies
(t *testing.T)
middleware/client_ip_test.go:184
FunctionTestClientIPFromXFFTrustedProxies_PanicsOnZero
(t *testing.T)
middleware/client_ip_test.go:239
FunctionTestClientIPFromXFF_NoTrustedPrefixes
(t *testing.T)
middleware/client_ip_test.go:55
FunctionTestClientIPFromXFF_PanicsOnBadPrefix
(t *testing.T)
middleware/client_ip_test.go:175
FunctionTestClientIPFromXFF_TrustedPrefixes
(t *testing.T)
middleware/client_ip_test.go:95
FunctionTestClientIPLastWriteWins
TestClientIPLastWriteWins locks down the implementation property that each ClientIPFrom* middleware unconditionally overwrites the context value when
middleware/client_ip_test.go:278
FunctionTestCompressor
(t *testing.T)
middleware/compress_test.go:16
FunctionTestCompressorDefaultTextTypes
(t *testing.T)
middleware/compress_test.go:112
FunctionTestCompressorWildcards
(t *testing.T)
middleware/compress_test.go:136
FunctionTestContentCharset
(t *testing.T)
middleware/content_charset_test.go:11
FunctionTestContentEncoding
(t *testing.T)
middleware/content_charset_test.go:113
FunctionTestContentEncodingMiddleware
(t *testing.T)
middleware/content_encoding_test.go:12
FunctionTestContentType
(t *testing.T)
middleware/content_type_test.go:12
FunctionTestCustomHTTPMethod
(t *testing.T)
mux_test.go:1765
FunctionTestEscapedURLParams
(t *testing.T)
mux_test.go:1725
← previousnext →201–300 of 435, ranked by callers