Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/go-chi/chi
/ functions
Functions
435 in github.com/go-chi/chi
⨍
Functions
435
◇
Types & classes
60
Method
Connect
HTTP-method routing along `pattern`
chi.go:97
Method
Create
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:34
Method
Create
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:35
Function
CreateArticle
CreateArticle persists the posted Article and returns it back to the client as an acknowledgement.
_examples/rest/main.go:155
Method
Delete
Delete adds the route `pattern` that matches a DELETE http method to execute the `handlerFn` http.HandlerFunc.
mux.go:149
Method
Delete
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:46
Method
Delete
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:47
Function
DeleteArticle
DeleteArticle removes an existing Article from our persistent store.
_examples/rest/main.go:201
Function
Example_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
Function
Example_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
Method
Flush
()
middleware/wrap_writer.go:147
Method
Flush
()
middleware/wrap_writer.go:172
Method
Flush
()
middleware/compress.go:349
Method
Get
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:38
Method
Get
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:39
Function
GetArticle
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
Function
GetHead
GetHead automatically route undefined HEAD requests to GET handlers.
middleware/get_head.go:10
Method
HandleFunc
HandleFunc adds the route `pattern` that matches any http method to execute the `handlerFn` http.HandlerFunc.
mux.go:121
Method
Handler
(next http.Handler)
middleware/route_headers.go:77
Method
Head
Head adds the route `pattern` that matches a HEAD http method to execute the `handlerFn` http.HandlerFunc.
mux.go:161
Function
Heartbeat
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
Method
Hijack
()
middleware/wrap_writer.go:178
Method
Hijack
()
middleware/wrap_writer.go:200
Method
Hijack
()
middleware/logger_test.go:17
Method
Hijack
()
middleware/compress.go:365
Method
Less
(i, j int)
tree.go:837
Method
List
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/users.go:30
Method
List
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:31
Function
ListArticles
(w http.ResponseWriter, r *http.Request)
_examples/rest/main.go:114
Function
Logger
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
Method
Match
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
Function
Maybe
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
Method
MethodFunc
MethodFunc adds the route `pattern` that matches `method` http method to execute the `handlerFn` http.HandlerFunc.
mux.go:137
Method
MethodNotAllowed
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
Method
Middlewares
Middlewares returns a slice of middleware handler functions.
mux.go:355
Function
New
New will create a new middleware handler from a http.Handler.
middleware/middleware.go:6
Method
NewLogEntry
NewLogEntry creates a new LogEntry for the request.
middleware/logger.go:98
Function
NextRequestID
NextRequestID generates the next request ID in the sequence.
middleware/request_id.go:94
Function
NoCache
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
Method
NotFound
NotFound sets a custom http.HandlerFunc for routing paths that could not be found. The default 404 handler is `http.NotFound`.
mux.go:203
Method
Options
Options adds the route `pattern` that matches an OPTIONS http method to execute the `handlerFn` http.HandlerFunc.
mux.go:167
Method
Options
(pattern string, h http.HandlerFunc)
chi.go:101
Function
PageRoute
PageRoute is a simple middleware which allows you to route a static GET request at the middleware stack level.
middleware/page_route.go:10
Method
Panic
(v interface{}, stack []byte)
middleware/logger.go:168
Method
Patch
Patch adds the route `pattern` that matches a PATCH http method to execute the `handlerFn` http.HandlerFunc.
mux.go:173
Method
Patch
(pattern string, h http.HandlerFunc)
chi.go:102
Function
PathRewrite
PathRewrite is a simple middleware which allows you to rewrite the request URL path.
middleware/path_rewrite.go:9
Function
Ping
Ping returns pong
_examples/router-walk/main.go:40
Function
PresentError
(r *http.Request, err error)
_examples/versions/data/errors.go:16
Method
Print
(v ...interface{})
middleware/recoverer_test.go:17
Function
Profiler
Profiler is a convenient subrouter used for mounting net/http/pprof. ie. func MyService() http.Handler { r := chi.NewRouter() // ..middlewares
middleware/profiler.go:22
Method
Push
(target string, opts *http.PushOptions)
middleware/wrap_writer.go:205
Method
Push
(target string, opts *http.PushOptions)
middleware/compress.go:372
Method
Put
Put adds the route `pattern` that matches a PUT http method to execute the `handlerFn` http.HandlerFunc.
mux.go:185
Method
Query
Query adds the route `pattern` that matches a QUERY http method to execute the `handlerFn` http.HandlerFunc.
mux.go:191
Method
ReadFrom
(src io.Reader)
middleware/wrap_writer_test.go:21
Function
RealIP
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
Function
Recoverer
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
Method
Render
(w http.ResponseWriter, r *http.Request)
_examples/versions/presenter/v3/article.go:25
Method
Render
(w http.ResponseWriter, r *http.Request)
_examples/versions/presenter/v1/article.go:16
Method
Render
(w http.ResponseWriter, r *http.Request)
_examples/rest/main.go:372
Method
Render
(w http.ResponseWriter, r *http.Request)
_examples/rest/main.go:410
Function
RequestID
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
Function
RequestSize
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
Method
Reset
Reset a routing context to its initial state.
context.go:82
Method
Route
(header, match string, middlewareHandler func(next http.Handler) http.Handler)
middleware/route_headers.go:48
Method
Routes
Routes returns a slice of routing information from the tree, useful for traversing available routes of a router.
mux.go:350
Method
Routes
Routes creates a REST router for the todos resource
_examples/todos-resource/users.go:12
Method
Routes
Routes creates a REST router for the todos resource
_examples/todos-resource/todos.go:12
Function
SearchArticles
SearchArticles searches the Articles data for a matching article. It's just a stub, but you get the idea.
_examples/rest/main.go:149
Method
ServeHTTP
(w http.ResponseWriter, r *http.Request)
chain.go:30
Function
SetHeader
SetHeader is a convenience handler to set a response header key/value
middleware/content_type.go:9
Method
Status
()
middleware/wrap_writer.go:122
Method
String
()
context.go:164
Function
SupressNotFound
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
Method
Sync
(w http.ResponseWriter, r *http.Request)
_examples/todos-resource/todos.go:51
Function
TestAdvisory_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
Function
TestAdvisory_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
Function
TestAdvisory_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
Function
TestBasicWriterDiscardsWritesToOriginalResponseWriter
(t *testing.T)
middleware/wrap_writer_test.go:63
Function
TestBasicWritesTeesWritesWithoutDiscard
(t *testing.T)
middleware/wrap_writer_test.go:43
Function
TestClientIPFromHeader
(t *testing.T)
middleware/client_ip_test.go:12
Function
TestClientIPFromHeader_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
Function
TestClientIPFromRemoteAddr
(t *testing.T)
middleware/client_ip_test.go:248
Function
TestClientIPFromRemoteAddr_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
Function
TestClientIPFromXFFTrustedProxies
(t *testing.T)
middleware/client_ip_test.go:184
Function
TestClientIPFromXFFTrustedProxies_PanicsOnZero
(t *testing.T)
middleware/client_ip_test.go:239
Function
TestClientIPFromXFF_NoTrustedPrefixes
(t *testing.T)
middleware/client_ip_test.go:55
Function
TestClientIPFromXFF_PanicsOnBadPrefix
(t *testing.T)
middleware/client_ip_test.go:175
Function
TestClientIPFromXFF_TrustedPrefixes
(t *testing.T)
middleware/client_ip_test.go:95
Function
TestClientIPLastWriteWins
TestClientIPLastWriteWins locks down the implementation property that each ClientIPFrom* middleware unconditionally overwrites the context value when
middleware/client_ip_test.go:278
Function
TestCompressor
(t *testing.T)
middleware/compress_test.go:16
Function
TestCompressorDefaultTextTypes
(t *testing.T)
middleware/compress_test.go:112
Function
TestCompressorWildcards
(t *testing.T)
middleware/compress_test.go:136
Function
TestContentCharset
(t *testing.T)
middleware/content_charset_test.go:11
Function
TestContentEncoding
(t *testing.T)
middleware/content_charset_test.go:113
Function
TestContentEncodingMiddleware
(t *testing.T)
middleware/content_encoding_test.go:12
Function
TestContentType
(t *testing.T)
middleware/content_type_test.go:12
Function
TestCustomHTTPMethod
(t *testing.T)
mux_test.go:1765
Function
TestEscapedURLParams
(t *testing.T)
mux_test.go:1725
← previous
next →
201–300 of 435, ranked by callers