Skip to content

Commit

Permalink
docs: fix & improve documentation (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerwill90 authored Jun 15, 2023
1 parent a66e6fa commit 4d29082
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ even for complex routing pattern.
**Redirect trailing slashes:** Inspired from [httprouter](https://github.com/julienschmidt/httprouter), the router automatically
redirects the client, at no extra cost, if another route match with or without a trailing slash.

**Automatic OPTIONS responses:** Inspired from [httprouter](https://github.com/julienschmidt/httprouter), the router has built-in native
**Automatic OPTIONS replies:** Inspired from [httprouter](https://github.com/julienschmidt/httprouter), the router has built-in native
support for [OPTIONS requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS).

Of course, you can also register custom `NotFound` and `MethodNotAllowed` handlers.
Expand Down Expand Up @@ -445,6 +445,7 @@ f := fox.New(

### Official middlewares
* [tigerwill90/otelfox](https://github.com/tigerwill90/otelfox): Distributed tracing with [OpenTelemetry](https://opentelemetry.io/)
* [tigerwill90/foxdump](https://github.com/tigerwill90/foxdump): Body dump middleware for capturing requests and responses payload.

## Handling OPTIONS Requests and CORS Automatically
The `WithAutoOptions` setting or the `WithOptionsHandler` registration enable automatic responses to OPTIONS requests.
Expand Down
6 changes: 3 additions & 3 deletions fox.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func New(opts ...Option) *Router {
return r
}

// NewTree returns a fresh routing Tree. It's safe to create multiple Tree concurrently. However, a Tree itself
// is not thread-safe and all its APIs that perform write operations should be run serially. Note that a Tree give
// direct access to the underlying sync.Mutex.
// NewTree returns a fresh routing Tree that inherits all registered router options. It's safe to create multiple Tree
// concurrently. However, a Tree itself is not thread-safe and all its APIs that perform write operations should be run
// serially. Note that a Tree give direct access to the underlying sync.Mutex.
// This API is EXPERIMENTAL and is likely to change in future release.
func (fox *Router) NewTree() *Tree {
tree := new(Tree)
Expand Down
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
NoMethodHandler
// RedirectHandler scope applies middleware to the internal redirect trailing slash handler.
RedirectHandler
// OptionsHandler scope applies middleware to the internal automatic OPTIONS handler.
// OptionsHandler scope applies middleware to the automatic OPTIONS handler.
OptionsHandler
// AllHandlers is a combination of all the above scopes, which means the middleware will be applied to all types of handlers.
AllHandlers = RouteHandlers | NoRouteHandler | NoMethodHandler | RedirectHandler | OptionsHandler
Expand Down Expand Up @@ -77,7 +77,7 @@ func WithMiddleware(m ...MiddlewareFunc) Option {

// WithMiddlewareFor attaches middleware to the router for a specified scope. Middlewares provided will be chained
// in the order they were added. The scope parameter determines which types of handlers the middleware will be applied to.
// Possible scopes include RouteHandlers (regular routes), NoRouteHandler, NoMethodHandler, RedirectHandler,
// Possible scopes include RouteHandlers (regular routes), NoRouteHandler, NoMethodHandler, RedirectHandler, OptionsHandler,
// and any combination of these. Use this option when you need fine-grained control over where the middleware is applied.
// This api is EXPERIMENTAL and is likely to change in future release.
func WithMiddlewareFor(scope MiddlewareScope, m ...MiddlewareFunc) Option {
Expand Down

0 comments on commit 4d29082

Please sign in to comment.