Controller
setResponse()
Signature
Section titled “Signature”setResponse() — returns void
Available in: controller
Category: Rendering Functions
Description
Section titled “Description”Sets content that Wheels will send to the client in response to the request.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
content | string | yes | — | The content to send to the client. |
Examples
Section titled “Examples”// 1. Override the response body with a plain string
setResponse("Maintenance mode active. Please try again later.");
// 2. Modify an already-rendered response in an after filter
// (e.g. append a debug comment to every HTML response)
private void function appendDebugComment() {
current = response();
setResponse(current & "<!-- rendered at #Now()# -->");
}
// 3. Replace the response with serialized data after a renderView() call
// (useful in tests or custom middleware-style filters)
setResponse(serializeJSON({status: "ok", timestamp: Now()}));