starlarky icon indicating copy to clipboard operation
starlarky copied to clipboard

Short Circuit Processing

Open mjallday opened this issue 3 years ago • 3 comments

Internal discussion

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.

mjallday avatar Feb 19 '21 21:02 mjallday