Struct Output

A response to user. Default content-type is "text/html".

struct Output ;
// Set status code to 404
output.status = 404

// Send a response. Same as: output.write("Sorry, page not found.");
output ~= "Sorry, page not found.";

Properties

NameTypeDescription
status[get] ushortRead status.
status[set] ushortSet response status. 200 by default.

Methods

NameDescription
addHeader (key, value) Add a http header. You can't set content-length, date, server, status or transfer-encoding headers. They are managed by serverino internally.
clear () Clear the output buffer.
clearHeaders () Clear all headers.
opAssign (v) Mute/unmute output. If false, serverino will not send any data to user.
opAssign () Clear the output buffer.
opOpAssign (data) Syntax sugar. Easier way to write output.
serveFile (path, guessMime) Serve a file from disk. If you want to delete the file after serving it, use serveFile!(OnFileServed.deleteFile).
setCookie (c) Add or edit a cookie. To delete a cookie, use cookie.invalidate() and then setCookie(cookie)
setMaxRequestTime (max) Override ServerinoConfig.setMaxRequestTime(Duration dur) for this request
write (data) Write data to output. You can write as many times as you want.