snapshot of https://github.com/go-chi/chi.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
Test / test (1.24.x, ubuntu-latest) (push) Successful in 2m56s
Test / test (1.25.x, ubuntu-latest) (push) Successful in 2m15s
Test / test (1.26.x, ubuntu-latest) (push) Successful in 2m23s
Test / test (1.27.x, ubuntu-latest) (push) Failing after 3m56s
Test / test (1.24.x, windows-latest) (push) Has been cancelled
Test / test (1.25.x, windows-latest) (push) Has been cancelled
Test / test (1.26.x, windows-latest) (push) Has been cancelled
Test / test (1.27.x, windows-latest) (push) Has been cancelled
Some checks failed
Test / test (1.24.x, ubuntu-latest) (push) Successful in 2m56s
Test / test (1.25.x, ubuntu-latest) (push) Successful in 2m15s
Test / test (1.26.x, ubuntu-latest) (push) Successful in 2m23s
Test / test (1.27.x, ubuntu-latest) (push) Failing after 3m56s
Test / test (1.24.x, windows-latest) (push) Has been cancelled
Test / test (1.25.x, windows-latest) (push) Has been cancelled
Test / test (1.26.x, windows-latest) (push) Has been cancelled
Test / test (1.27.x, windows-latest) (push) Has been cancelled
This commit is contained in:
33
_examples/custom-method/main.go
Normal file
33
_examples/custom-method/main.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
)
|
||||
|
||||
func init() {
|
||||
chi.RegisterMethod("LINK")
|
||||
chi.RegisterMethod("UNLINK")
|
||||
chi.RegisterMethod("WOOHOO")
|
||||
}
|
||||
|
||||
func main() {
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.RequestID)
|
||||
r.Use(middleware.Logger)
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("hello world"))
|
||||
})
|
||||
r.MethodFunc("LINK", "/link", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("custom link method"))
|
||||
})
|
||||
r.MethodFunc("WOOHOO", "/woo", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("custom woohoo method"))
|
||||
})
|
||||
r.HandleFunc("/everything", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("capturing all standard http methods, as well as LINK, UNLINK and WOOHOO"))
|
||||
})
|
||||
http.ListenAndServe(":3333", r)
|
||||
}
|
||||
Reference in New Issue
Block a user