diff --git a/CHANGELOG.md b/CHANGELOG.md index faa81de..99a9f58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,15 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher ### UNRELEASED +### Changed + - Go updated from `1.17.5` up to `1.17.6` -- Add "Host" and "X-Forwarded-For" Header to error pages + +### Added + +- `Host` and `X-Forwarded-For` Header to error pages [#61] + +[#61]:https://github.com/tarampampam/error-pages/pull/61 ## v2.4.0 diff --git a/internal/http/core/headers.go b/internal/http/core/headers.go index 18ee605..bdab0ef 100644 --- a/internal/http/core/headers.go +++ b/internal/http/core/headers.go @@ -25,7 +25,7 @@ const ( // RequestID is a unique ID that identifies the request - same as for backend service RequestID = "X-Request-ID" - // Forward-For identifies the user of this session + // ForwardedFor identifies the user of this session ForwardedFor = "X-Forwarded-For" // Host identifies the hosts origin diff --git a/internal/tpl/properties.go b/internal/tpl/properties.go index 75b0f30..dda8b9d 100644 --- a/internal/tpl/properties.go +++ b/internal/tpl/properties.go @@ -13,7 +13,7 @@ type Properties struct { // only string properties with a "token" tag, please ServicePort string `token:"service_port"` RequestID string `token:"request_id"` ForwardedFor string `token:"forwarded_for"` - Host string `token:"host"` + Host string `token:"host"` ShowRequestDetails bool } diff --git a/internal/tpl/properties_test.go b/internal/tpl/properties_test.go index 6be28be..e0b6f62 100644 --- a/internal/tpl/properties_test.go +++ b/internal/tpl/properties_test.go @@ -9,17 +9,17 @@ import ( func TestProperties_Replaces(t *testing.T) { props := tpl.Properties{ - Code: "foo", - Message: "bar", - Description: "baz", - OriginalURI: "aaa", - Namespace: "bbb", - IngressName: "ccc", - ServiceName: "ddd", - ServicePort: "eee", - RequestID: "fff", - ForwardedFor:"ggg", - Host: "hhh", + Code: "foo", + Message: "bar", + Description: "baz", + OriginalURI: "aaa", + Namespace: "bbb", + IngressName: "ccc", + ServiceName: "ddd", + ServicePort: "eee", + RequestID: "fff", + ForwardedFor: "ggg", + Host: "hhh", } r := props.Replaces() diff --git a/test/hurl/code_502_json.hurl b/test/hurl/code_502_json.hurl index 2274c03..d9a9130 100644 --- a/test/hurl/code_502_json.hurl +++ b/test/hurl/code_502_json.hurl @@ -7,6 +7,8 @@ X-Ingress-Name: baz X-Service-Name: aaa X-Service-Port: bbb X-Request-ID: ccc +X-Forwarded-For: ddd +Host: eee HTTP/* 200 @@ -23,6 +25,8 @@ jsonpath "$.details.ingress_name" == "baz" jsonpath "$.details.service_name" == "aaa" jsonpath "$.details.service_port" == "bbb" jsonpath "$.details.request_id" == "ccc" +jsonpath "$.details.forwarded_for" == "ddd" +jsonpath "$.details.host" == "eee" jsonpath "$.details.timestamp" isInteger # X-Format in the action diff --git a/test/hurl/code_502_xml.hurl b/test/hurl/code_502_xml.hurl index 943e92b..de4a4fb 100644 --- a/test/hurl/code_502_xml.hurl +++ b/test/hurl/code_502_xml.hurl @@ -7,6 +7,8 @@ X-Ingress-Name: baz X-Service-Name: aaa X-Service-Port: bbb X-Request-ID: ccc +X-Forwarded-For: ddd +Host: eee HTTP/* 200 @@ -23,7 +25,7 @@ xpath "string(//error/details/serviceName)" == "aaa" xpath "string(//error/details/servicePort)" == "bbb" xpath "string(//error/details/requestID)" == "ccc" xpath "string(//error/details/forwardedFor)" == "ddd" -xpath "string(//error/details/host)" == "fff" +xpath "string(//error/details/host)" == "eee" xpath "string(//error/details/timestamp)" exists # X-Format in the action