ginCorrelationID

package module
v0.0.0-...-c3b4290 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2018 License: MIT Imports: 3 Imported by: 0

README

Gin-CorrelationID

Go Report Card

CorrelationID middleware for Golang Gin Web framework

Use case

Gin-CorraltaionID middleware is used to check if there is an corralation id added into http request header. If that header is not found middleware adds it to http request.

Correlation ID enriches logs and reduces your headache when it comes to tracing up an actions produced by application.

How to use it in Gin web-api

func main(){
    router := gin.New()
	router.Use(ginCorrelationID.CorrelationIDMiddleware())

    router.GET("api/test", func(c *gin.Context) {
		c.String(http.StatusOK, c.Request.Header.Get("CorrelationID"))
	})
}

Dependencies

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CorrelationIDMiddleware

func CorrelationIDMiddleware() gin.HandlerFunc

CorrelationIDMiddleware adds correlationID if it's not specified in HTTP request

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL