Commit 168723a0 authored by Abiola Ibrahim's avatar Abiola Ibrahim

Added escaped versions of uri, query and path.

parent c748ef94
......@@ -3,6 +3,7 @@ package middleware
import (
"net"
"net/http"
"net/url"
"path"
"strconv"
"strings"
......@@ -38,11 +39,13 @@ func NewReplacer(r *http.Request, rr *responseRecorder, emptyValue string) Repla
}
return "http"
}(),
"{host}": r.Host,
"{path}": r.URL.Path,
"{query}": r.URL.RawQuery,
"{fragment}": r.URL.Fragment,
"{proto}": r.Proto,
"{host}": r.Host,
"{path}": r.URL.Path,
"{path_escaped}": url.QueryEscape(r.URL.Path),
"{query}": r.URL.RawQuery,
"{query_escaped}": url.QueryEscape(r.URL.RawQuery),
"{fragment}": r.URL.Fragment,
"{proto}": r.Proto,
"{remote}": func() string {
if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" {
return fwdFor
......@@ -60,7 +63,8 @@ func NewReplacer(r *http.Request, rr *responseRecorder, emptyValue string) Repla
}
return port
}(),
"{uri}": r.URL.RequestURI(),
"{uri}": r.URL.RequestURI(),
"{uri_escaped}": url.QueryEscape(r.URL.RequestURI()),
"{when}": func() string {
return time.Now().Format(timeFormat)
}(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment