https://github.com/darvaza-proxy/middleware
func(http.Handler) http.Handler collection
https://github.com/darvaza-proxy/middleware
go golang handler middleware
Last synced: about 1 month ago
JSON representation
func(http.Handler) http.Handler collection
- Host: GitHub
- URL: https://github.com/darvaza-proxy/middleware
- Owner: darvaza-proxy
- License: mit
- Created: 2023-03-17T16:23:39.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-27T08:41:38.000Z (4 months ago)
- Last Synced: 2025-01-27T09:29:48.268Z (4 months ago)
- Topics: go, golang, handler, middleware
- Language: Shell
- Homepage: https://darvaza.org/middleware
- Size: 70.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# func(http.Handler) http.Handler
[](https://pkg.go.dev/darvaza.org/middleware)
[](https://codebeat.co/projects/github-com-darvaza-proxy-middleware-main)## General Middleware
* `NOOP` does nothing
## Content Negotiation
* `AcceptMiddleware()` alters the `Accept` header so only a given set is passed
to the next handler in the chain## Error Handling Middleware
* `WithErrorHandlerMiddleware()`
## Special Handlers
* HTTPSRedirectHandler a handler that will redirect to https if
non-https, or return 404 already https## Error Handlers
we define an ErrorHandler as a function like:
```go
func (http.ResponseWriter, *http.Request, error)
````WithErrorHandler()` and `ErrorHandler()` add and read the context
for such handler