Update documentation to include pre-hook-command property.

This commit is contained in:
Adnan Hajdarevic 2019-12-05 22:15:15 +01:00
parent 54cfc6bcbd
commit 64942c9793
2 changed files with 26 additions and 4 deletions

View File

@ -20,6 +20,17 @@ Hooks are defined as JSON objects. Please note that in order to be considered va
* `pass-file-to-command` - specifies a list of entries that will be serialized as a file. Incoming [data](Referencing-Request-Values.md) will be serialized in a request-temporary-file (otherwise parallel calls of the hook would lead to concurrent overwritings of the file). The filename to be addressed within the subsequent script is provided via an environment variable. Use `envname` to specify the name of the environment variable. If `envname` is not provided `HOOK_` and the name used to reference the request value are used. Defining `command-working-directory` will store the file relative to this location, if not provided, the systems temporary file directory will be used. If `base64decode` is true, the incoming binary data will be base 64 decoded prior to storing it into the file. By default the corresponding file will be removed after the webhook exited. * `pass-file-to-command` - specifies a list of entries that will be serialized as a file. Incoming [data](Referencing-Request-Values.md) will be serialized in a request-temporary-file (otherwise parallel calls of the hook would lead to concurrent overwritings of the file). The filename to be addressed within the subsequent script is provided via an environment variable. Use `envname` to specify the name of the environment variable. If `envname` is not provided `HOOK_` and the name used to reference the request value are used. Defining `command-working-directory` will store the file relative to this location, if not provided, the systems temporary file directory will be used. If `base64decode` is true, the incoming binary data will be base 64 decoded prior to storing it into the file. By default the corresponding file will be removed after the webhook exited.
* `trigger-rule` - specifies the rule that will be evaluated in order to determine should the hook be triggered. Check [Hook rules page](Hook-Rules.md) to see the list of valid rules and their usage * `trigger-rule` - specifies the rule that will be evaluated in order to determine should the hook be triggered. Check [Hook rules page](Hook-Rules.md) to see the list of valid rules and their usage
* `trigger-rule-mismatch-http-response-code` - specifies the HTTP status code to be returned when the trigger rule is not satisfied * `trigger-rule-mismatch-http-response-code` - specifies the HTTP status code to be returned when the trigger rule is not satisfied
* `pre-hook-command` - specifies the command that will be run before the hook gets invoked.
* to the STDIN of this command, webhook will pass a JSON string representation of an object with the following properties:
* `hookID` - ID of the hook that got matched
* `method` - HTTP(s) method used by the client (i.e. GET, POST, etc...)
* `URI` - URI which client requested
* `host` - value of the `Host` header sent by the client
* `remoteAddress` - client's IP address
* `query` - object with query parameters and their respective values
* `headers` - object with headers and their respective values
* `base64EncodedBody` - base64 encoded request body
* Output of this command __MUST__ be valid JSON string which will be parsed by the webhook and accessible using the `context` as source when referencing values.
## Examples ## Examples
Check out [Hook examples page](Hook-Examples.md) for more complex examples of hooks. Check out [Hook examples page](Hook-Examples.md) for more complex examples of hooks.

View File

@ -1,7 +1,18 @@
# Referencing request values # Referencing request values
There are three types of request values: There are four types of request values:
1. HTTP Request Header values 1. Context values
These are the values provided by the `pre-hook-command` output.
```json
{
"source": "context",
"name": "parameter-name"
}
```
2. HTTP Request Header values
```json ```json
{ {
@ -10,7 +21,7 @@ There are three types of request values:
} }
``` ```
2. HTTP Query parameters 3. HTTP Query parameters
```json ```json
{ {
@ -19,7 +30,7 @@ There are three types of request values:
} }
``` ```
3. Payload (JSON or form-value encoded) 4. Payload (JSON or form-value encoded)
```json ```json
{ {
"source": "payload", "source": "payload",