Categorygithub.com/lightning-contrib/requestid
modulepackage
1.0.0
Repository: https://github.com/lightning-contrib/requestid.git
Documentation: pkg.go.dev

# README

requestid

The Lightning Request ID middleware is designed to provide unique request IDs for every incoming request and add them to logs and response headers. This helps with tracking request in a distributed system, making it easier to debug and troubleshoot issues.

Installation

To use the Request ID middleware, you can install it using the following command:

go get github.com/lightning-contrib/requestid

Usage

Here is an example of how to use requestid middleware:

package main

import (
	"github.com/go-labx/lightning"
	"github.com/lightning-contrib/requestid"
)

func main() {
	app := lightning.NewApp()
	app.Use(requestid.Default())

	app.Get("/ping", func(ctx *lightning.Context) {
		ctx.JSON(200, map[string]string{
			"message": "pong",
		})
	})

	app.Run()
}

You can also use the New() function, it also returns a middleware, but it allows for customization of the config struct through the use of variadic Options arguments.

app.Use(requestid.New(
    requestid.WithAlphabet("1234567890"),
    requestid.WithHeaderKey("X-Custom-ID"),
    requestid.WithSize(16)),
)

API Documentation

For detailed API documentation and usage examples, please refer to the documentation.

Contributing

If you'd like to contribute to lightning, please see CONTRIBUTING.md for guidelines.

License

lightning is licensed under the MIT License.

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author