Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
binding
✓ gitea.com/go-chi/binding
Bind and validate request data in a Chi handler
package main
import (
"net/http"
"gitea.com/go-chi/binding"
"github.com/go-chi/chi"
)
type Input struct {
Name string `json:"name" binding:"required"`
}
func handler(w http.ResponseWriter, r *http.Request) {
var input Input
if err := binding.Bind(r, &input); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
}
func main() {
r := chi.NewRouter()
r.Post("/", handler)
http.ListenAndServe(":8080", r)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.0.0-20230415142243-04b515c6d669latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.