Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "html" "log" "net/http" "github.com/elblox/requestid" ) func handler(w http.ResponseWriter, r *http.Request) { rid, _ := requestid.FromContext(r.Context()) log.Println("Running hello handler:", rid) fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) } func main() { h := http.HandlerFunc(handler) http.Handle("/", requestid.RequestIDHandler(h)) log.Fatal(http.ListenAndServe(":8080", nil)) }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const HeaderName = "X-Request-ID"
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext returns the request id from context.
func NewContext ¶
NewContext creates a context with request id set as context value as well as twirp request header.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.