The HttpClientActor
(HTTP client) is a Coral Actor that can perform the POST, GET, PUT, and DELETE HTTP methods on a specified URL.
The creation JSON of the HttpClientActor actor (see Coral Actor) has "type": "httpclient"
. The params
value is a JSON:
field | type | required | description |
---|---|---|---|
url |
string | yes | url to which to connect |
method |
string | yes | the HTTP method to use to connect |
headers |
JSON object | no | additional headers to send for the request |
{
"data": {
"type": "actors",
"attributes": {
"type": "httpclient"
"params": {"url": "http://www.google.com", "method": "GET"}
}
}
}
The HttpClientActor
is triggered by a JSON. The HttpClientActor
will perform a HTTP method on the defined field ‘url’ with as payload
the received trigger JSON (can be an empty object). Currently the client supports the following HTTP methods:
POST GET PUT DELETE
{
"my payload"
}
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. The body’s value is a JSON
string, unless the server responds with JSON content, then it is a JSON object.
The HttpClientActor
does not keep a state
The HttpClientActor
does not collect state from other actors.
When the timer is defined in the HttpClientActor
’s instantiation JSON, the actor will act according to this definition, so it’s possible to
e.g. poll an URL every second and emit the results to all the actors to which the HttpClientActor
is defined to emit to.