Skip to main content
Version: 3.3.1

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 NameDescriptionTypeDefault
addressBind addressstring-
pathUrl path on which to accept queriesstring/
content-typeContent type to return with responsestring-
certPath to the TLS certificate to be used (TLS requires both cert and key to be valid)path-
keyPath to the TLS private to be used (TLS requires both cert and key to be valid)path-
queryQuery parameter to readstring-
only-bodyAccept only the body, ignoring metadataboolfalse
json-bodyFor cases where body is already in JSON formatboolfalse
custom-responseResponse to send back to clientstring-
source-ip-fieldIf specified the source IP address for the http request to the server will be stored in the specified fieldfield-

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