Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
maxLevel3

...

response.sendError(code, [message])

Sending an error Sets the status code of the response to the responsegiven error code

Example

Code Block
languagejs
linenumberstrue
... 
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
languagejs
linenumberstrue
... 
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
languagejs
linenumberstrue
... 
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
languagejs
linenumberstrue
... 
response.setHeader(key, value)
...

...