inline middlewares

This commit is contained in:
2025-08-16 14:43:41 +05:30
parent 855b82e9df
commit 216fe93a55
3 changed files with 39 additions and 25 deletions

View File

@@ -153,16 +153,17 @@ func TestRouterGroup(t *testing.T) {
func TestRouterResource(t *testing.T) {
r := New()
r.Resource("/users", func(res *Resource) {
res.Index(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "All users")
})
r.Resource("/users",
func(res *Resource) {
res.Index(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "All users")
})
res.View(func(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
fmt.Fprintf(w, "User %s", id)
res.View(func(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
fmt.Fprintf(w, "User %s", id)
})
})
})
ts := httptest.NewServer(r)
defer ts.Close()