inline middlewares
This commit is contained in:
17
mux_test.go
17
mux_test.go
@@ -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()
|
||||
|
Reference in New Issue
Block a user