Skip to content

A plugin for generating request ID for use with go-kit

License

Notifications You must be signed in to change notification settings

varunvs/requestid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Description

A plugin for go-kit to generate request id and store it in context. Also, write the request id in the response as well. It will look for X-Request-Id header and use that as the request id. If it is not available, it'll generate one.

It does not use UUID for generating the id. A random string is generated using the built-in rand.Read function and is encoded as a string.

The obtained request id is stored in context as "requestID" key.

Usage

Use it as a ServerOption while building the server. For example:

    import kithttp "github.com/go-kit/kit/transport/http"
	opts := []kithttp.ServerOption{
		kithttp.ServerBefore(util.RequestIDToContext()),
		kithttp.ServerAfter(util.RequestIDToResponse()),
	}

About

A plugin for generating request ID for use with go-kit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages