Documentation
¶
Overview ¶
Example ¶
package main
import (
"fmt"
"html"
"log"
"net/http"
"github.com/ascarter/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 ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext returns the request id from context
func NewContext ¶
NewContext creates a context with request id
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.