Skip to content

A set of frequently used Go http handlers

License

Notifications You must be signed in to change notification settings

faryon93/handlers

Repository files navigation

Handlers

Documentation Go Report Card Last Release

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