HttpClientActor

The HttpClientActor is a Coral Actor that can perform POST, GET, PUT, and DELETE HTTP requests on a specified URL.

Creating a HttpClientActor

The HttpClientActor has "type": "httpclient". The params value is a JSON object with the following fields:

field type required description
mode string yes Either static or dynamic.
field string no When mode is set to dynamic, the field to get the URL from.
url string yes The URL to connect to.
method string yes The HTTP method (verb) to use.
headers JSON no Additional headers to send for the request.

Example

An example of a static HTTPClient is given below:

{
  "type": "httpclient",
  "params": {
    "mode": "static",
    "url": "http://www.google.com", 
    "method": "POST"
  }
}

In this case, the actor will post the JSON it receives through its trigger to http://www.google.com.

An example of a dynamic HTPTClient is given below:

{
  "type": "httpclient",
  "params": {
    "mode": "dynamic",
    "field": "url",
    "method": "POST"
  }
}

When the actor now receives a JSON object with a field “url” in it, it will post the received JSON to that URL.

Trigger

The HttpClientActor is triggered by a JSON object. The HttpClientActor will perform the specified HTTP on the URL obtained as described above. The payload is the received trigger JSON object. Currently the client supports the following HTTP methods:

  • POST
  • GET
  • PUT
  • DELETE

Emit

The HttpClientActor emits a json with the status, header and body of the response of the http method that was triggered. The header field is an JSON object with as fields the different header fields and as values the header values.

State

The HttpClientActor does not keep state.

Collect

The HttpClientActor does not collect state from other actors.

Timer

The HttpClientActor does not define a timer function.