diff --git a/proxy/plugin/grout_client.py b/proxy/plugin/grout_client.py index afbf5fed..925c713f 100644 --- a/proxy/plugin/grout_client.py +++ b/proxy/plugin/grout_client.py @@ -10,7 +10,7 @@ """ -from typing import Tuple +from typing import Tuple, Optional from proxy.proxy import GroutClientBasePlugin from proxy.common.types import HostPort @@ -25,9 +25,10 @@ class GroutClientPlugin(GroutClientBasePlugin): request: HttpParser, origin: HostPort, server: HostPort, - ) -> Tuple[str, HttpParser]: - print(request, origin, server, '->', route) - print(request.header(b'host'), request.path) + ) -> Tuple[Optional[str], HttpParser]: + # print(request, origin, server, '->', route) + # print(request.header(b'host'), request.path) + # # Send to localhost:7001 irrespective of the # original "route" value provided to the grout client # OR any custom host:upstream mapping provided through the @@ -35,4 +36,8 @@ class GroutClientPlugin(GroutClientBasePlugin): # # Optionally, you can also strip path like this: # request.path = b"/" + # + # Return None for route to drop the request + # return None, request + # return 'http://localhost:7001', request diff --git a/proxy/proxy.py b/proxy/proxy.py index d9dea572..ccce5933 100644 --- a/proxy/proxy.py +++ b/proxy/proxy.py @@ -528,7 +528,7 @@ class GroutClientBasePlugin(ABC): request: HttpParser, origin: HostPort, server: HostPort, - ) -> Tuple[str, HttpParser]: + ) -> Tuple[Optional[str], HttpParser]: """Returns a valid grout route string. You MUST override this method. This method returns 2-tuple where @@ -537,6 +537,7 @@ class GroutClientBasePlugin(ABC): For a simple pass through, simply return the "route" argument value itself. You can also return a dynamic value based upon "request" and "origin" information. E.g. sending to different upstream services based upon request Host header. + Return None as "route" value to drop the request. You can also modify the original request object and return. Common examples include strip-path scenario, where you would like to strip the path before