A set of frequently used Go http handlers and middleware functions.
# download library
$: go get github.com/faryon93/handlers
# place on top of your go file
import "github.com/faryon93/handlers"
| Handler | Description |
|---|---|
| Forbidded() | Default 403 forbidden handler. |
| NoRobots() | Writes a robots.txt file, which disallows the access to everything. |
Adapter functions can be chained with the real handler function or other adapter functions.
| Adapter | Description |
|---|---|
| CORS(age, orgins) | Configures gorilla/handlers/cors in a convenient way |
| Benchmark() | Logs the execution time of every request using logrus |
| Enabled(en) | Denys access if en is false |
| Keyed(reqKey) | Restrict access to requests, having param "key" matching reqKey |
| Paged(limit) | Paging: Parses skip and limit from query parameters |
| Recaptcha(key) | Restricts access if recaptcha is invalid |
| RestrictOrigin(orgins...) | Rejects all request having an origin which is not on the list |