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 Name | Type | Description | Default |
---|---|---|---|
address | string | Bind address | - |
path | string | Url path on which to accept queries | / |
content-type | string | Content type to return with response | - |
cert | path | Path to the TLS certificate to be used (TLS requires both cert and key to be valid) | - |
key | path | Path to the TLS private to be used (TLS requires both cert and key to be valid) | - |
query | string | Query parameter to read | - |
only-body | bool | Accept only the body, ignoring metadata | false |
json-body | bool | For cases where body is already in JSON format | false |
custom-response | string | Response to send back to client | - |
source-ip-field | field | If 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