Response Interceptors
Last updated
Last updated
Saloon already allows you to add functionality to your requests in the form of plugins, but if you would like to intercept the response before it is passed back to you, you can add a response interceptor. These can be added into Saloon plugins, or they can be added to the boot
method on the Connector/Request.
This response interceptor will tell all responses to "throw" an exception if it fails. Response interceptors provide you with the SaloonRequest and the request and the SaloonResponse.
Saloon Responses are also "Macroable" which means you can add your own methods to them to use later.
After we have defined the macro, we can use it like this.
If you are looking to overwrite Saloon's response methods or if you would like to add lots of your own methods, consider creating a custom response. .