Define a Guardrail Handler
See the Python handler definition for general handler arguments, inputs, outputs and initialization.
Error handling and response status
- Processing errors are suppressed and ignored by the middleware; the request passes through.
- In
preprocessororpostprocessormode, return anuclio_sdk.Responsewith a non-zerostatus_codeto change the response status. - In
wrapprocessormode, return anuclio_sdk.Responsewith the corresponding status code to prevent propagation to the upstream service.
Processing phase
The processing-phase header is appended to the event object. Its possible values are:
| Phase | Header value |
|---|---|
| Process request headers | 1 |
| Process request body | 2 |
| Process response headers | 4 |
| Process response body | 5 |