requestid is an requestId(traceId) middleware for Gin
`hostname-pid-initrandvalue-sequence`
go get github.com/things-go/requestid
package main
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/things-go/requestid"
)
func main() {
router := gin.New()
router.Use(requestid.RequestId())
router.GET("/", func(c *gin.Context) {
fmt.Println(requestid.FromRequestId(c.Request.Context()))
fmt.Println(requestid.GetRequestId(c))
})
router.Run(":8080")
}
This project is under MIT License. See the LICENSE file for the full license text.