https://github.com/potatogopher/gorilla-middleware
"Chaining" Middleware with Gorilla Mux
https://github.com/potatogopher/gorilla-middleware
golang gorilla-mux http
Last synced: 29 days ago
JSON representation
"Chaining" Middleware with Gorilla Mux
- Host: GitHub
- URL: https://github.com/potatogopher/gorilla-middleware
- Owner: potatogopher
- Created: 2018-12-30T03:49:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-30T03:55:23.000Z (almost 7 years ago)
- Last Synced: 2025-01-26T16:33:10.516Z (8 months ago)
- Topics: golang, gorilla-mux, http
- Language: Go
- Homepage:
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chaining Middleware with Gorilla Mux
This little API shows you how you can use Gorilla's `Router.Use` function to register middlewares. This approach is an alternative to wrapping middlewares around middlewares and so on.## Setup
```zsh
$ git clone git@github.com:potatogopher/gorilla-middleware.git
$ cd gorilla-middleware
$ go run main.go
```## Middlewares
**Logger**
The logging middleware will log data about the requests being made by a client.
**CORS**
CORS provides Cross-Origin Resource Sharing. CORS will be handled for all routes that recognize the `OPTIONS` method. [More info](https://github.com/gorilla/mux/issues/381)
**Recovery Handler**
The recovery handler will prevent a panic from happening. It will end up responding with a 500 Internal Server Error.