async def __postprocess__( payload: Union[Something, SomethingNotFound], context: EventContext, response: PostprocessHook) -> Union[Something, SomethingNotFound]: if isinstance(payload, SomethingNotFound): logger.debug(context, '404 - File %s not found', payload.id) response.status = 404 return payload
async def __postprocess__(message: Optional[MyMessage], context: EventContext, response: PostprocessHook) -> Union[MyMessage, str]: """ Special handler to customize what's returned as a response to the POST request received. Sets status to 400 if the message was invalid and returns just a message. Returns the validated message otherwise. Notice that this step can occur after MyMessage was already submitted to the stream. """ if message is None: response.status = 400 return "invalid data received" return message
async def __postprocess__( payload: Union[Something, SomethingNotFound], context: EventContext, response: PostprocessHook) -> Union[Something, SomethingNotFound]: if isinstance(payload, SomethingNotFound): response.status = 404 return payload