Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

baac-tech/zlogres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zlogres

made-with-Go

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

Table of Contents

Installation

  go get -u github.com/baac-tech/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/baac-tech/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

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages