mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-24 08:26:58 -04:00
* Create request_id directive #1590 * Address Comments * Fix TestListenerAddrEqual * requestid: Add some tests * Address Comments by tobya * Address Comments
This commit is contained in:
@@ -205,4 +205,7 @@ const (
|
||||
|
||||
// MitmCtxKey is the key for the result of MITM detection
|
||||
MitmCtxKey caddy.CtxKey = "mitm"
|
||||
|
||||
// RequestIDCtxKey is the key for the U4 UUID value
|
||||
RequestIDCtxKey caddy.CtxKey = "request_id"
|
||||
)
|
||||
|
||||
@@ -443,6 +443,7 @@ var directives = []string{
|
||||
// services/utilities, or other directives that don't necessarily inject handlers
|
||||
"startup",
|
||||
"shutdown",
|
||||
"requestid",
|
||||
"realip", // github.com/captncraig/caddy-realip
|
||||
"git", // github.com/abiosoft/caddy-git
|
||||
|
||||
|
||||
@@ -243,6 +243,9 @@ func (r *replacer) getSubstitution(key string) string {
|
||||
case "{path_escaped}":
|
||||
u, _ := r.request.Context().Value(OriginalURLCtxKey).(url.URL)
|
||||
return url.QueryEscape(u.Path)
|
||||
case "{request_id}":
|
||||
reqid, _ := r.request.Context().Value(RequestIDCtxKey).(string)
|
||||
return reqid
|
||||
case "{rewrite_path}":
|
||||
return r.request.URL.Path
|
||||
case "{rewrite_path_escaped}":
|
||||
|
||||
Reference in New Issue
Block a user