diff --git a/README.md b/README.md index c950386..8596080 100644 --- a/README.md +++ b/README.md @@ -90,3 +90,29 @@ r.GET("/", func(c *gin.Context) { c.String(http.StatusOK, "id:"+requestid.Get(c)) }) ``` + +You can also get the request identifier from response header: + +``` +> curl -i "http://127.0.0.1:8080" + +HTTP/1.1 200 OK +Content-Type: text/plain; charset=utf-8 +X-Request-ID: 77966910-3912-4193-9b74-267491c51700 +Content-Length: 39 + +id:77966910-3912-4193-9b74-267491c51700 +``` + +When http request with custom identifier, gin server return the custom identifier in response header. + +``` +> curl -i -H "X-Request-ID:test" "http://127.0.0.1:8080" + +HTTP/1.1 200 OK +Content-Type: text/plain; charset=utf-8 +X-Request-Id: 1688221042 +Content-Length: 13 + +id:test +``` \ No newline at end of file