Skip to content

zlogres is a middleware for GoFiber that logging about api elapsed time since request to response.

Notifications You must be signed in to change notification settings

owlsome-official/zlogres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zlogres

made-with-Go Watsize-Library CodeQL

zlogres is a middleware for GoFiber that logging about api elapsed time since request to response.

Table of Contents

Installation

  go get -u github.com/owlsome-official/zlogres

Signatures

func New(config ...Config) fiber.Handler

Examples

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

// Config defines the config for middleware.
type Config struct {
  // Optional. Default: nil
  Next func(c *fiber.Ctx) bool

  // Optional. Default: "requestid"
  RequestIDContextKey string
}

Default Config

var ConfigDefault = Config{
  Next:                nil,
  RequestIDContextKey: "requestid",
}

Dependencies

Example Usage

Please go to example/main.go

Don't forget to run:

  go mod tidy

Note: Custom usage please focus on Custom section

About

zlogres is a middleware for GoFiber that logging about api elapsed time since request to response.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages