ResponseBuilder¶
Basic interface for a ResponseBuilder that can be used with chaining method calls.
It enforces a strict order of build steps by only making the next step available
as a return to a function required to transition. E.g. You must call set_status(...)
in order to get back a ResponseBuilderHeaders to add
headers to the response. You need to call finish_headers()
in order to
be able to add body data with ResponseBuilderBody.
You can always reset the builder to start out fresh from the beginning.
Implementations may take advantage of reset()
by returning itself here,
allowing for object reuse.
Use ResponseBuilderBody.build() to finally build the response into a ByteSeqIter, taylored for use with Session.send_raw().
Example usage:
let builder: ResponseBuilder = Responses.builder()
builder.set_status(StatusOK)
.add_header("Content-Length", "4")
.add_header("Content-Type", "text/plain; charset=UTF-8")
.add_header("Server", "pony-http")
.finish_headers()
.add_chunk("COOL")
.build()
Public Functions¶
set_status¶
Parameters¶
- status: Status val
Returns¶
reset¶
Returns¶
- ResponseBuilder ref