Overview
The JSMA response provides functionality for handling responsesresponseĀ allows to manipulate the response that will be sent to the client
Info |
---|
What canĀ JSMA response do for me?You could easily use the JSMA response to handle responsesmanipulate the response that will be sent to the client |
Index
Table of Contents | ||
---|---|---|
|
...
response.sendError(code, [message])
Sending an error Sets the status code of the response to the responsegiven error code
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... var file = files.findByUuid(request.parameter('id')); if (file === null) { response.sendError(404); return; } ... |
...
response.sendFile(file, [mime])
Sending Sets a JSMA file to be sent as the response body.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... var mimeType = request.parameter("mimetype"); var fileId = request.parameter("id"); var file = files.findById(fileId); if (file !== null) { response.sendFile(file, mimeType); } ... |
...
response.sendRedirect(target, [temp])
Sending Sends a redircet redirect response to the responseclient
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... response.sendRedirect(target, [temp]) ... |
...
response.setHeader(key, value)
Setting Sets a key with a /value to pair in the header of the response headers.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... response.setHeader(key, value) ... |
...