Skip to content

nikonm/gin-dumper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GIN dumper

codecov Build Status

  • Gin middleware handler for dumping body and headers of request(and response).
  • You can easily use it with your logger
Sample
package main

import (
    "github.com/gin-gonic/gin"
    "github.com/nikonm/gin-dumper"
    "fmt"
)

func main () {
    router := gin.New()

    opt := &gin_dumper.Options{TrimNewLineInRequest: "   "}

    router.Use(gin_dumper.Dumper(func(output *gin_dumper.Output) {
        fmt.Printf("REQUEST: %s %s Headers: %v Body: %s Resp: %d JsonBody: %s\n",
			output.Request.Method,
			output.Request.Url.RequestURI(),
			output.Request.Headers,
			output.Request.Body,
			output.Response.StatusCode,
			output.Response.Body,
		)
    }, opt))

    router.POST("/test", func(c *gin.Context) {
		// Some Action
    })
	
    router.Run(":80")
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages