diff --git a/README.md b/README.md index abf27db..8cbf5f1 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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. diff --git a/fox.go b/fox.go index 6d984a5..ab18f8c 100644 --- a/fox.go +++ b/fox.go @@ -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) diff --git a/options.go b/options.go index 8c64a41..fe72cc1 100644 --- a/options.go +++ b/options.go @@ -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 @@ -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 {