starlarky
starlarky copied to clipboard
Short Circuit Processing
Goal: Allow processing to short circuit and return a response to the caller before the entire request is processed.
Method: Allow returning a Response
object instead of the payload. When a Response
object is returned the proxy would no longer continue processing and instead return the Response. This is similar to how Flask works.
Example
def validate(input):
# do something
def process(input, ctx):
if not validate(input):
return abort(400, 'Input failed validation')
return input
Conceptually it would allow this flow
client -> proxy (pre) -> upstream -> proxy (post) -> client
client -> proxy (pre) *abort* -> client
Where the upstream and post processing is no longer invoked.