{"action":"created","issue":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/1182","repository_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/1182/labels{/name}","comments_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/1182/comments","events_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/1182/events","html_url":"https://github.com/spring-cloud/spring-cloud-netflix/issues/1182","id":165316053,"number":1182,"title":"Zuul Send responseDataStream and disable route filters","user":{"login":"Aloren","id":1207414,"avatar_url":"https://avatars.githubusercontent.com/u/1207414?v=3","gravatar_id":"","url":"https://api.github.com/users/Aloren","html_url":"https://github.com/Aloren","followers_url":"https://api.github.com/users/Aloren/followers","following_url":"https://api.github.com/users/Aloren/following{/other_user}","gists_url":"https://api.github.com/users/Aloren/gists{/gist_id}","starred_url":"https://api.github.com/users/Aloren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aloren/subscriptions","organizations_url":"https://api.github.com/users/Aloren/orgs","repos_url":"https://api.github.com/users/Aloren/repos","events_url":"https://api.github.com/users/Aloren/events{/privacy}","received_events_url":"https://api.github.com/users/Aloren/received_events","type":"User","site_admin":false},"labels":[{"id":222072230,"url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/labels/waiting%20for%20feedback","name":"waiting for feedback","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-13T13:08:34Z","updated_at":"2016-11-08T12:19:39Z","closed_at":null,"body":"In my custom pre filter I want to set `responseDataStream` and disable route filters.\nMy first implementation was:\n\n```\n//sets response input stream\nctx.setResponseDataStream(new ByteArrayInputStream(body));\n// disables route filters\nctx.setSendZuulResponse(false);\n```\n\nBut this code doesn't work, because `SendResponseFilter` doesn't send responseDataStream if sendZuulResponse is false. My workaround was following:\n\n```\n//sets response input stream\nctx.setResponseDataStream(new ByteArrayInputStream(body));\n//Disable SimpleHostRoutingFilter\nctx.setRouteHost(null);\n//Disable RibbonRoutingFilter\nctx.remove(\"serviceId\");\n```\n\nAs for me such implementation is too bad. \nI would like to have ability to turn off route filters without changing of response sending flow.\nThanks.\n"},"comment":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/comments/259122413","html_url":"https://github.com/spring-cloud/spring-cloud-netflix/issues/1182#issuecomment-259122413","issue_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/1182","id":259122413,"user":{"login":"Aloren","id":1207414,"avatar_url":"https://avatars.githubusercontent.com/u/1207414?v=3","gravatar_id":"","url":"https://api.github.com/users/Aloren","html_url":"https://github.com/Aloren","followers_url":"https://api.github.com/users/Aloren/followers","following_url":"https://api.github.com/users/Aloren/following{/other_user}","gists_url":"https://api.github.com/users/Aloren/gists{/gist_id}","starred_url":"https://api.github.com/users/Aloren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aloren/subscriptions","organizations_url":"https://api.github.com/users/Aloren/orgs","repos_url":"https://api.github.com/users/Aloren/repos","events_url":"https://api.github.com/users/Aloren/events{/privacy}","received_events_url":"https://api.github.com/users/Aloren/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T12:19:39Z","updated_at":"2016-11-08T12:19:39Z","body":"The idea of the whole post is to serve cached responses (byte arrays) via Zuul. \r\nTo implement this firstly I need to disable both routing filters: `RibbonRoutingFilter` and `SimpleHostRoutingFilter`. This can be done by the following code:\r\n```\r\n//Disable SimpleHostRoutingFilter\r\nctx.setRouteHost(null);\r\n//Disable RibbonRoutingFilter\r\nctx.remove(\"serviceId\");\r\n```\r\nOr by:\r\n```\r\nctx.setSendZuulResponse(false);\r\n```\r\nWhy these 2 solutions? Let's see method `shouldFilter` from `SimpleHostRoutingFilter` and `RibbonRoutingFilter`:\r\n```\r\n\tpublic boolean shouldFilter() {\r\n\t\treturn RequestContext.getCurrentContext().getRouteHost() != null\r\n\t\t\t\t&& RequestContext.getCurrentContext().sendZuulResponse();\r\n\t}\r\n\r\n\tpublic boolean shouldFilter() {\r\n\t\tRequestContext ctx = RequestContext.getCurrentContext();\r\n\t\treturn (ctx.getRouteHost() == null && ctx.get(\"serviceId\") != null\r\n\t\t\t\t&& ctx.sendZuulResponse());\r\n\t}\r\n```\r\nAs you can see from these lines to disable both of them you either need to setSendZuulResponse to false or remove serviceId and routeHost from `RequestContext`.\r\n\r\nSo I would like to have ability to disable route filters by something like: `ctx.disableRouting();`. Is that possible to implement or are there any reasons not to do that?\r\n"}}
{"actor":{"display_login":"Aloren"}}