Internal
Using this module you can call "cross-app" to utilize functionality across the cloud server.
cloud.internal
Request
.request
Makes an internal request to another app/module on the server.
Signature
cloud.internal.request(path, args_tbl[, method])
Parameters
Name | Description | Type | Default | Required |
---|---|---|---|---|
path |
The endpoint for the app relative to host. | string |
nil |
Y |
args_tbl |
Arguments you want to pass to the method (or {}). | table |
nil |
Y |
method |
HTTP method to send the request as. | constant | POST |
N |
Returns
An internal request returns three properties, in order of importance:
Name | Description | Type |
---|---|---|
data |
The data table with any results from the call. | table |
headers |
The response headers as name=value table. | table |
status |
The HTTP response code, if any. | number |
Example
--grab just the returned data table (hypothetical app) local data = cloud.internal.request('/scores/list', {count=10, sort='DESC'})
data
contains top 10 scores as table array.
Or, you can pull in all the values:
local data, headers, status = internal.request('/scores/list', {})