How would I cancel a request and return a response from a component


#1

Suppose I have a fancy-pancy component that does something like return an authorized user, and ONLY an authorized user. I’d rather not get to calling the function if the component cannot initialize.

Can I, ala Flask, raise an “http status” as an exception from a component, aborting the rest of the execution of the request? Just raise 403 and be done?


#2

Raise any subclass of exceptions.HTTPException

See here: https://github.com/encode/apistar/blob/master/apistar/exceptions.py