zlogres is a middleware for GoFiber that logging about api elapsed time since request to response.
go get -u github.com/owlsome-official/zlogres
func New(config ...Config) fiber.Handler
Import the middleware package that is part of the Fiber web framework
import (
"github.com/gofiber/fiber/v2"
"github.com/owlsome-official/zlogres"
)
After you initiate your Fiber app, you can use the following possibilities:
// Default
app.Use(zlogres.New())
// this middleware supported the `requestid` middleware
app.Use(requestid.New())
app.Use(zlogres.New())
// Or extend your config for customization
app.Use(requestid.New(requestid.Config{
ContextKey: "transaction-id",
}))
app.Use(zlogres.New(zlogres.Config{
RequestIDContextKey: "transaction-id",
}))
// Config defines the config for middleware.
type Config struct {
// Optional. Default: nil
Next func(c *fiber.Ctx) bool
// Optional. Default: "requestid"
RequestIDContextKey string
}
var ConfigDefault = Config{
Next: nil,
RequestIDContextKey: "requestid",
}
Please go to example/main.go
Don't forget to run:
go mod tidy
Note: Custom usage please focus on Custom
section