HTTP Server Adapter

The http_server adapter creates an http server and reads points from incoming http requests.

read http_server

Read points by pushing the contents of http requests into the Juttle flowgraph

read http_server -port port
                 -method method
                 -timeField timeField
                 -separator character
                 -commentSymbol character
                 -ignoreEmptyLines true/false
                 -allowIncompleteLines true/false
Parameter Description Required?
-port Port for HTTP Server to listen on No; default: 8080
-method HTTP method to use

Currently only supports POSTor PUT
No; default: POST
-timeField The name of the field to use as the time field

The specified field will be renamed to timein the body of the HTTP request. If the points already contain a field called time that field is overwritten. This is useful when the source data contains a time field whose values are not valid time stamps.
No; defaults to keeping the timefield as is
-rootPath When the incoming data is JSON, use the specified path into the incoming object (expressed as field1.field2 to emit points No
-separator When -format 'csv'is used, you can specify the separator between columns in a CSV file. No: defaults to ,
-commentSymbol When -format 'csv'is used, you can specify the comment character that prefixes comment lines in a CSV file. No: defaults to ,
-ignoreEmptyLines When -format 'csv'is used, you can skip empty lines in a CSV file. No: defaults to false
-allowIncompleteLines When -format 'csv'is used, you can allow for parsing of incomplete lines in a CSV file. No: defaults to false

Currently the read http_server adapter will automatically parse incoming data based off of the content-type header. Here are the currently supported content-types:

* `text/csv`: for [CSV](https://tools.ietf.org/html/rfc4180) data
* `application/json` for [JSON](https://tools.ietf.org/html/rfc7159) data
* `application/json` for [JSON lines](http://jsonlines.org/) data

Example

Create a simple http server on port 2000.

/*
 * Create an http server on port 2000. View points in a table.
 *
 */

 read http_server -port 2000
 | view table;

Send points to server by running this curl command:

curl -H "Content-Type: application/json" -X POST -d '{"hello": "world"}'  http://localhost:2000