http-server
Run HTTP server
Example
action:
http-server:
address: 127.0.0.1:8000
output:
{
"body": "",
"method": "GET",
"query": {},
"url": "",
"headers": {
"accept": "*/*",
"host": "localhost:8000",
"user-agent": "curl/7.58.0"
}
}
Field Name | Description | Type | Default |
---|---|---|---|
address | Bind address | string | - |
path | Url path on which to accept queries | string | / |
content-type | Content type to return with response | string | - |
cert | Path to the TLS certificate to be used (TLS requires both cert and key to be valid) | path | - |
key | Path to the TLS private to be used (TLS requires both cert and key to be valid) | path | - |
query | Query parameter to read | string | - |
only-body | Accept only the body, ignoring metadata | bool | false |
json-body | For cases where body is already in JSON format | bool | false |
custom-response | Response to send back to client | string | - |
source-ip-field | If specified the source IP address for the http request to the server will be stored in the specified field | field | - |
address
Bind address
Type: string
Example
action:
http-server:
address: 127.0.0.1:8000
path
Url path on which to accept queries
Otherwise any path will be accepted
Type: string
Example
action:
http-server:
address: 127.0.0.1:8000
path: /foo/bar
output:
{"body":"","method":"GET","query":{},"url":"/foo/bar","headers":{"accept":"*/*","host":"localhost:8000","user-agent":"curl/7.58.0"}}
content-type
Content type to return with response
Type: string
Example
action:
http-server:
address: 127.0.0.1:8000
content-type: application/text
cert
Path to the TLS certificate to be used (TLS requires both cert
and key
to be valid)
Type: path
key
Path to the TLS private to be used (TLS requires both cert
and key
to be valid)
Type: path
query
Query parameter to read
Assume a query like curl http://localhost:3030?foo=barbar
Type: string
Example
action:
http-server:
address: 127.0.0.1:8000
query: foo
output:
{"_raw":"barbar"}
only-body
Accept only the body, ignoring metadata
Assume a query like curl -d 'hello dolly' 'http://localhost:3030'
Type: bool
Example
action:
http-server:
address: 127.0.0.1:8000
only-body: true
output:
{"_raw":"hello dolly"}
json-body
For cases where body is already in JSON format
Assume a query like curl -d '{"msg":"hello"}' 'http://localhost:3030'
Type: bool
Example
action:
http-server:
address: 127.0.0.1:8000
json-body: true
output:
{"msg":"hello"}
custom-response
Response to send back to client
Type: string
Example
action:
http-server:
address: 127.0.0.1:8000
custom-response: |
{"msg":"hello!"}
source-ip-field
If specified the source IP address for the http request to the server will be stored in the specified field
Type: field