return function(context)
end
context.route.destination read
context.route.alive read
context.route.mapper.server read
context.route.mapper.srcMatch read
context.route.mapper.dst read
context.route.mapper.providerID read
context.route.mapper.pingURL read
context.route.mapper.matchType read
context.route.mapper.redirectType read
context.route.mapper.assetsLocation read
context.route.mapper.assetsWebRoot read
context.route.mapper.assetsSPA read
context.request.method read
context.request.remoteAddr read
context.request.requestURI read
context.request.host read
context.request.readBody() callable, fill context.request.body field, returns error
context.request.body read (without readBody() returns nil) / write
context.request.header.get(name) callable, returns string
context.request.header.set(name, value) callable
context.request.header.add(name, value) callable
context.request.header.delete(name) callable
For read/write response fields you must call next function with captureResponse = true
option
context.response.statusCode read/write
context.response.body read/write
context.response.header.get(name) callable, returns string
context.response.header.set(name, value) callable
context.response.header.add(name, value) callable
context.response.header.delete(name) callable
context.next(options) callable, options is not required
Options is a table
{
captureResponse = true default false
}
Key/value store
local kv = require('kv')
err = kv.set(key, value, [timeout])
Key and Value must be a strings
Returns error if occurred.
Not required timeout
must be a string in go duration format.
res, err = kv.get(key)
Key must be a string
Returns string value and error, if occurred.
err = kv.delete(key)
Key must be a string
Returns error, if occurred.
local log = require('log')
log.debug(args...)
log.info(args...)
log.warn(args...)
log.error(args...)
local http = require('http')
http.MethodGet returns string GET
http.MethodHead returns string HEAD
http.MethodPost returns string POST
http.MethodPut returns string PUT
http.MethodPatch returns string PATCH
http.MethodDelete returns string DELETE
http.MethodConnect returns string CONNECT
http.MethodOptions returns string OPTIONS
http.MethodTrace returns string TRACE
resp, err = http.get(url)
URL must be a string
Returns response table (see bellow) and error if occurred
resp, err = http.post(url, contentType, body)
URL, contentType and body must be strings
Returns response table (see bellow) and error if occurred
resp, err = http.request(method, url, [options])
Method and URL must be string.
Not required options must be a table. All options fields are not require.
Options:
{
timeout = <string> string in go duration format, by default '30s'
body = <string> request body, by default empty
headers = { request headers, by default empty
key1 = value1,
key2 = value2,
}
}
Response is a table
{
code = <number> response status code
body = <string> response body
headers = { response headers
key1 = {value1, value11},
key2 = {value2},
}
}