Recorder
A response recorder is one of the Iris specific http.ResponseWriter
. It records the response body, status code and headers that you can manipulate at any handler inside a route's handlers chain.
Call
Context.Record()
before send data.The
Context.Recorder()
returns a ResponseRecorder. Its methods can be used to manipulate or retrieve the response.
The ResponseRecorder
type contains the standard Iris ResponseWriter methods plus the following methods.
Body returns the body tracked from the writer so far. Do not use this for edit.
Use this to clear the body.
Use Write/Writef/WriteString
to stream write and SetBody/SetBodyString
to set body instead.
Reset headers to their original state, before Context.Record
call.
Clear all headers.
Reset resets the response body, headers and the status code header.
Example
Record operation log in global Interceptor.
Register the routes...
Or to remove the need of ctx.Next
in your main handlers, modify the Iris handlers execution rules as follows.
In addition to that, Iris provides a comprehensive API for Transactions. Learn more about it by running an example.
Last updated