diff --git a/rest/middleware.go b/rest/middleware.go index ba03fb8..15121a6 100644 --- a/rest/middleware.go +++ b/rest/middleware.go @@ -58,6 +58,7 @@ func adapterFunc(handler HandlerFunc) http.HandlerFunc { request := &Request{ origRequest, nil, + "", map[string]interface{}{}, } diff --git a/rest/middleware_test.go b/rest/middleware_test.go index 63b3d1a..abf2ee4 100644 --- a/rest/middleware_test.go +++ b/rest/middleware_test.go @@ -40,6 +40,7 @@ func TestWrapMiddlewares(t *testing.T) { r := &Request{ nil, nil, + "", map[string]interface{}{}, } diff --git a/rest/request.go b/rest/request.go index c4eb381..a9e90f8 100644 --- a/rest/request.go +++ b/rest/request.go @@ -21,6 +21,9 @@ type Request struct { // Map of parameters that have been matched in the URL Path. PathParams map[string]string + // The PathExp of the route that is safisfying this request + PathExp string + // Environment used by middlewares to communicate. Env map[string]interface{} } diff --git a/rest/request_test.go b/rest/request_test.go index 1467c92..1e3eeb2 100644 --- a/rest/request_test.go +++ b/rest/request_test.go @@ -16,6 +16,7 @@ func defaultRequest(method string, urlStr string, body io.Reader, t *testing.T) return &Request{ origReq, nil, + "", map[string]interface{}{}, } } diff --git a/rest/router.go b/rest/router.go index f7ab713..f458505 100644 --- a/rest/router.go +++ b/rest/router.go @@ -48,8 +48,9 @@ func (rt *router) AppFunc() HandlerFunc { return } - // a route was found, set the PathParams + // a route was found, set the PathParams and PathExp request.PathParams = params + request.PathExp = route.PathExp // run the user code handler := route.Func