diff --git a/internal/hook/hook.go b/internal/hook/hook.go index 738e623..19809e7 100644 --- a/internal/hook/hook.go +++ b/internal/hook/hook.go @@ -454,7 +454,7 @@ func (ha *Argument) Get(r *Request) (string, error) { return "", errors.New("request is nil") } - switch ha.Name { + switch strings.ToLower(ha.Name) { case "remote-addr": return r.RawRequest.RemoteAddr, nil case "method": diff --git a/internal/hook/hook_test.go b/internal/hook/hook_test.go index 184243b..e9f29e4 100644 --- a/internal/hook/hook_test.go +++ b/internal/hook/hook_test.go @@ -262,7 +262,7 @@ var argumentGetTests = []struct { {"header", "a", map[string]interface{}{"A": "z"}, nil, nil, nil, "z", true}, {"url", "a", nil, map[string]interface{}{"a": "z"}, nil, nil, "z", true}, {"payload", "a", nil, nil, map[string]interface{}{"a": "z"}, nil, "z", true}, - {"request", "method", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "POST", true}, + {"request", "METHOD", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "POST", true}, {"request", "remote-addr", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "127.0.0.1:1234", true}, {"string", "a", nil, nil, map[string]interface{}{"a": "z"}, nil, "a", true}, // failures