Response Interceptors
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.
Example Response Interceptor
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.
This interceptor example is a plugin pre-built into Saloon, have a look at the AlwaysThrowsOnErrors plugin
Macroable
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.
Custom Responses
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. Read more.
Last updated