Improve HTTP handler documentation

This commit is contained in:
Preetha Appan 2017-10-21 20:51:37 -05:00
parent 0c5f5e2821
commit 2c2e032eec
1 changed files with 7 additions and 10 deletions

View File

@ -32,8 +32,8 @@ in a JSON body when using agent configuration or as CLI flags for the watch comm
## Handlers ## Handlers
The watch configuration specifies the view of data to be monitored. The watch configuration specifies the view of data to be monitored.
Once that view is updated, the specified handler is invoked. Supported handlers Once that view is updated, the specified handler is invoked. Handlers can be either an
are any executable or HTTP endpoint. A handler receives JSON formatted data executable or a HTTP endpoint. A handler receives JSON formatted data
with invocation info, following a format that depends on the type of the watch. with invocation info, following a format that depends on the type of the watch.
Each watch type documents the format type. Because they map directly to an HTTP Each watch type documents the format type. Because they map directly to an HTTP
API, handlers should expect the input to match the format of the API. A Consul API, handlers should expect the input to match the format of the API. A Consul
@ -66,15 +66,12 @@ the `args` to run under a shell, eg. `"args": ["sh", "-c", "..."]`.
### HTTP endpoint ### HTTP endpoint
A HTTP handler sends a HTTP request when a watch is invoked. The JSON A HTTP handler sends a HTTP request when a watch is invoked. The JSON
invocation info is sent as a payload along the request. Consul index is sent in invocation info is sent as a payload along the request. The response contains the Consul index as a header named `X-Consul-Index`.
the header `X-Consul-Index`. Any response is logged.
The HTTP handler can be configured by setting `handler_type` to `http`. The The HTTP handler can be configured by setting `handler_type` to `http`. Additional handler options
`http_handler_config` map must provide a `path` field with a URL to the HTTP are set using `http_handler_config`. The only required parameter is the `path` field which specifies the URL to the HTTP
endpoint. HTTP method is `POST` as a default, but can be set to any method. endpoint. Consul uses `POST` as the default http method, but this can be set to any method.
Though a JSON payload is sent in all cases. The `header`, `timeout` and Other optional fields are `header`, `timeout` and`tls_skip_verify`. The watch invocation data is always sent as a JSON payload.
`tls_skip_verify` field is also optional and configured the same way as in
[HTTP checks](/docs/agent/checks.html).
Here is an example configuration: Here is an example configuration: