gin_request_id

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestID

func RequestID() gin.HandlerFunc

RequestID is a middleware that adds a `request_id` value to the context as well as a `X-Request-ID` header to the response.

The `request_id` is got from the request header "X-Request-ID", and if not found, a new one is generated as a UUIDv3 based on the client IP, request method, request URI and time (time is got from `c.GetString("start_time")` and if not found, it is set to time.Now())

All request_ids are generated by a single instance of uuid.Gen with a constant namespace, which is a random UUIDv4 (or uuid.Nil if errs), determined when this middleware is initialized.

An early Use of this middleware is recommended to make sure the request_id is set for other middlewares.

Types

This section is empty.

Jump to

Keyboard shortcuts

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