https://github.com/faryon93/handlers
A set of frequently used Go http handlers
https://github.com/faryon93/handlers
go handler http middleware
Last synced: 12 months ago
JSON representation
A set of frequently used Go http handlers
- Host: GitHub
- URL: https://github.com/faryon93/handlers
- Owner: faryon93
- License: mit
- Created: 2018-03-23T11:20:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-24T10:27:39.000Z (almost 7 years ago)
- Last Synced: 2025-03-28T10:28:22.115Z (about 1 year ago)
- Topics: go, handler, http, middleware
- Language: Go
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: security.go
Awesome Lists containing this project
README
# Handlers
[](http://godoc.org/github.com/faryon93/handlers)
[](https://goreportcard.com/report/github.com/faryon93/handlers)
[](https://github.com/faryon93/handlers/releases)
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"
## Content: Handlers
| Handler | Description |
| ------------- | ------------------------------------------------------------------- |
| Forbidded() | Default 403 forbidden handler. |
| NoRobots() | Writes a robots.txt file, which disallows the access to everything. |
## Content: Adapters
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 |