Skip to main content
Version: 3.5.2

Input: http-server

Run HTTP server

Example

Pipe Language Snippet:

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 Summary

Field NameTypeDescriptionDefault
addressstringBind address-
pathstringUrl path on which to accept queries/
content-typestringContent type to return with response-
certpathPath to the TLS certificate to be used (TLS requires both cert and key to be valid)-
keypathPath to the TLS private to be used (TLS requires both cert and key to be valid)-
querystringQuery parameter to read-
only-bodyboolAccept only the body, ignoring metadatafalse
json-bodyboolFor cases where body is already in JSON formatfalse
custom-responsestringResponse to send back to client-
source-ip-fieldfieldIf specified the source IP address for the http request to the server will be stored in the specified field-

Fields

address

Type: string

Bind address

Example

Pipe Language Snippet:

http-server:
address: 127.0.0.1:8000

path

Type: string

Default: /

Url path on which to accept queries

Otherwise any path will be accepted

Example

Pipe Language Snippet:

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

Type: string

Content type to return with response

Example

Pipe Language Snippet:

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

cert

Type: path

Path to the TLS certificate to be used (TLS requires both cert and key to be valid)

key

Type: path

Path to the TLS private to be used (TLS requires both cert and key to be valid)

query

Type: string

Query parameter to read

Assume a query like curl http://localhost:3030?foo=barbar

Example

Pipe Language Snippet:

http-server:
address: 127.0.0.1:8000
query: foo

Output:

{"_raw":"barbar"}

only-body

Type: bool

Default: false

Accept only the body, ignoring metadata

Assume a query like curl -d 'hello dolly' 'http://localhost:3030'

Example

Pipe Language Snippet:

http-server:
address: 127.0.0.1:8000
only-body: true

Output:

{"_raw":"hello dolly"}

json-body

Type: bool

Default: false

For cases where body is already in JSON format

Assume a query like curl -d '{"msg":"hello"}' 'http://localhost:3030'

Example

Pipe Language Snippet:

http-server:
address: 127.0.0.1:8000
json-body: true

Output:

{"msg":"hello"}

custom-response

Type: string

Response to send back to client

Example

Pipe Language Snippet:

http-server:
address: 127.0.0.1:8000
custom-response: |
{"msg":"hello!"}

source-ip-field

Type: field

If specified the source IP address for the http request to the server will be stored in the specified field