Skip to content

Commit

Permalink
output = false to skip body
Browse files Browse the repository at this point in the history
  • Loading branch information
trikko committed May 13, 2023
1 parent e9c2e2a commit c9abe0f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions source/serverino/interfaces.d
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,20 @@ struct Output
*/
void opOpAssign(string op, T)(T data) if (op == "~") { write(data.to!string); }

/**
* Mute/unmute output. You must set this before writing any data to output
* --------------------
* output = false; // Mute the output.
* output ~= "Hello world"; // Serverino will not send this to user.
* --------------------
*/
void opAssign(in bool v) {
if (_internal._headersSent)
throw new Exception("Can't change output mode. Too late. Just sent.");

_internal._sendBody = v;
}

/// Write data
@safe void write(string data = string.init) { write(data.representation); }

Expand Down

0 comments on commit c9abe0f

Please sign in to comment.