Skip to content

Commit

Permalink
Fix README.md examples
Browse files Browse the repository at this point in the history
Removes unused imports, spaces as indentation (which breaks rendered format) and a mistake in `Bundle.With` arguments
  • Loading branch information
meandnano authored and umputun committed Mar 11, 2024
1 parent a3e31e8 commit db96dce
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ Here's a complete example demonstrating route grouping and middleware usage:
package main

import (
"fmt"
"net/http"

"github.com/go-pkgz/routegroup"
)

Expand All @@ -75,15 +74,15 @@ func main() {
apiGroup.HandleFunc("GET /hello", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, API!"))
})

// add another group with its own set of middlewares
protectedGroup := apiGroup.Group()
protectedGroup.Use(authMiddleware)
protectedGroup.HandleFunc("GET /protected", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Protected API!"))
})
w.Write([]byte("Protected API!"))
})

http.ListenAndServe(":8080", mux)
http.ListenAndServe(":8080", mux)
}
```

Expand All @@ -92,7 +91,7 @@ func main() {
You can also apply middleware to specific routes inside the group without modifying the group's middleware stack:

```go
apiGroup.With(corsMiddleware, helloHandler).Handle("GET /hello",helloHandler)
apiGroup.With(corsMiddleware, apiMiddleware).Handle("GET /hello", helloHandler)
```

**Alternative Usage with `Route`**
Expand Down

0 comments on commit db96dce

Please sign in to comment.