Module service
Access external services.
This module provides actions for accessing external services, such as webservices.
Info:
- Copyright: 2011-2015 Chad Phillips
- Author: Chad Phillips
Actions
http_request | Make an HTTP request to a external server. |
Tables
last_http_request | Last HTTP request storage. |
Actions
- http_request
-
Make an HTTP request to a external server.
Only the http:// protocol is supported.
The status of the completed request is stored in the last_http_request storage area.
If the request returns a '200' status code, then the body of the response will be stored according to the parameter settings.
- action string http_request
- fragment string (Optional) A fragment to append to the URL. It will be properly escaped before sending.
- password string (Optional) A password to use for basic authentication. 'user' parameter must also be provided.
- path string (Optional) The server path to send the request to, no leading or trailing slash.
- port int (Optional) The port to send the request to. Default is 80.
- query tab (Optional) A table of query parameters to append to the URL. Keys must be only numbers, letters, and underscores, values can be any string and will be properly URL escaped before sending.
- response
string
(Optional) The format to expect the response in:
lua: A string that represents a Lua table, of the following format: return { foo = 'bar', } The table data will be loaded into the specified storage area. Table values cannot contain a table. raw: A string of raw data. This will be stored in the specified storage area under the 'raw' storage key.
Default is 'raw'.
- server string (Optional) The server to send the request to. Default is 'localhost'.
- storage_area string (Optional) The storage area to store the response in. Defaults to 'service'.
- user string (Optional) A user name to use for basic authentication.
Usage:
{ action = "http_request", fragment = "some fragment", password = "secret", path = "path/to/resource", port = 80, query = { foo = "bar", baz = "two words" }, response = "raw", server = "www.example.com", storage_area = "my_http_request", user = "bob", }