Syntax
response($status_code, $result, $content_type)
Description
Creates a response object that will be returned to an HTTP request
Parameters
| Name |
Type |
Description |
Mandatory |
Default |
| status_code |
Number |
Status code for the response. HTTP response codes are specified here, e.g. 200 (OK) or 404 (NOT FOUND) |
yes |
|
| result |
|
Content of the response |
yes |
|
| content_type |
String |
| Content type of the response. Must match the answer |
|
no |
application/json |
Examples
example 1
response(404, {"message":"Element could not be found"});
example 2
response(
500,
"<html>
<head><title>Error 500 Server Error</title></head>
<body><h2>HTTP ERROR 500 Server Error</h2></body>
</html>",
"text/html");