go-middlewares
is a collection of commonly used middlewares in Go.
- The
ErrorHandlerMiddleware
is a middleware function designed to handle panics and errors that may occur during the execution of an HTTP handler.
Here's an example of how to use it in your code:
// Create a new HTTP handler and wrap it with the ErrorHandlerMiddleware.
handler := ErrorHandlerMiddleware(yourHandler)
// Use the wrapped handler for your server.
http.Handle("/your-route", handler)
// Start your HTTP server.
http.ListenAndServe(":8080", nil)
- The
LogHandlerMiddleware
is designed to log HTTP requests made to your web application. It captures various details about the request and logs them to your preferred output, which is especially useful for debugging and monitoring.
// Create a new HTTP handler and wrap it with the LogHandlerMiddleware.
handler := LogHandlerMiddleware(yourHandler)
// Use the wrapped handler for your HTTP server.
http.Handle("/your-route", handler)
// Start your HTTP server.
http.ListenAndServe(":8080", nil)
go get github.com/space-code/go-middleware
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Please feel free to help out with this project! If you see something that could be made better or want a new feature, open up an issue or send a Pull Request!
Nikita Vasilev, [email protected]
go-middlewares is available under the MIT license. See the LICENSE file for more info.