From e32ca852e0da65afb3997cd4ca180ddd3447aa13 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 7 Apr 2020 17:38:27 +0300 Subject: [PATCH] api/router/static: allow to specify body dst (#1486) Signed-off-by: Vasiliy Tolstov --- static.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/static.go b/static.go index 3c2c25d..09271c7 100644 --- a/static.go +++ b/static.go @@ -191,6 +191,7 @@ func (r *staticRouter) Endpoint(req *http.Request) (*api.Service, error) { Host: ep.apiep.Host, Method: ep.apiep.Method, Path: ep.apiep.Path, + Body: ep.apiep.Body, Stream: ep.apiep.Stream, }, Services: services, @@ -274,6 +275,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) { for k, v := range matches { md[fmt.Sprintf("x-api-field-%s", k)] = v } + md["x-api-body"] = ep.apiep.Body *req = *req.Clone(context.WithValue(ctx, metadata.MetadataKey{}, md)) break pathLoop } @@ -285,6 +287,7 @@ func (r *staticRouter) endpoint(req *http.Request) (*endpoint, error) { // we got here, so its a match return ep, nil } + // no match return nil, fmt.Errorf("endpoint not found for %v", req) }