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

Function main

_examples/custom-method/main.go:16–33  ·  _examples/custom-method/main.go::main
()

Source from the content-addressed store, hash-verified

14}
15
16func main() {
17 r := chi.NewRouter()
18 r.Use(middleware.RequestID)
19 r.Use(middleware.Logger)
20 r.Get("/", func(w http.ResponseWriter, r *http.Request) {
21 w.Write([]byte("hello world"))
22 })
23 r.MethodFunc("LINK", "/link", func(w http.ResponseWriter, r *http.Request) {
24 w.Write([]byte("custom link method"))
25 })
26 r.MethodFunc("WOOHOO", "/woo", func(w http.ResponseWriter, r *http.Request) {
27 w.Write([]byte("custom woohoo method"))
28 })
29 r.HandleFunc("/everything", func(w http.ResponseWriter, r *http.Request) {
30 w.Write([]byte("capturing all standard http methods, as well as LINK, UNLINK and WOOHOO"))
31 })
32 http.ListenAndServe(":3333", r)
33}

Callers

nothing calls this directly

Calls 5

UseMethod · 0.95
GetMethod · 0.95
MethodFuncMethod · 0.95
HandleFuncMethod · 0.95
WriteMethod · 0.65

Tested by

no test coverage detected