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-
custom-responseResponse to send back to clientstring-
pathUrl path on which to accept queriesstring/
queryQuery parameter to readstring-
only-bodyAccept only the body, ignoring metadataboolfalse
json-bodyFor cases where body is already in JSON formatboolfalse
content-typeContent type to return with responsestring-

address

Bind address

Type: string

Example

action:

http-server:
  address: 127.0.0.1:8000

custom-response

Response to send back to client

Type: string

Example

action:

http-server:
  address: 127.0.0.1:8000
  custom-response: success

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"}}

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"}

content-type

Content type to return with response

Type: string

Example

action:

http-server:
  address: 127.0.0.1:8000
  content-type: application/text