",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "token"
+ }
+ }
+ }
+ }
+]
+```
+
+## A simple webhook with a secret key in GET query
+
+__Not recommended in production due to low security__
+
+`example.com:9000/hooks/simple-one` - won't work
+`example.com:9000/hooks/simple-one?token=42` - will work
+
+```json
+[
+ {
+ "id": "simple-one",
+ "execute-command": "/path/to/command.sh",
+ "response-message": "Executing simple webhook...",
+ "trigger-rule":
+ {
+ "match":
+ {
+ "type": "value",
+ "value": "42",
+ "parameter":
+ {
+ "source": "url",
+ "name": "token"
+ }
+ }
+ }
+ }
+]
+```
+
+# JIRA Webhooks
+[Guide by @perfecto25](https://sites.google.com/site/mrxpalmeiras/notes/jira-webhooks)
+
+# Pass File-to-command sample
+
+## Webhook configuration
+
+
+[
+ {
+ "id": "test-file-webhook",
+ "execute-command": "/bin/ls",
+ "command-working-directory": "/tmp",
+ "pass-file-to-command":
+ [
+ {
+ "source": "payload",
+ "name": "binary",
+ "envname": "ENV_VARIABLE", // to use $ENV_VARIABLE in execute-command
+ // if not defined, $HOOK_BINARY will be provided
+ "base64decode": true, // defaults to false
+ }
+ ],
+ "include-command-output-in-response": true
+ }
+]
+
+
+## Sample client usage
+
+Store the following file as `testRequest.json`.
+
+
+{"binary":"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2lpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9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VmotFoKplMHgoGg6PkrFarjXQ6/bFcLj/G5W1E+3NaX4KZeDx+dX5+7kg4HBlmrC6JoiDFYrGhROLM/mp1Y6JSqdCd3/SW0GUqEAjkl5ZyHTSHKBQKnO6a9khD2m5cr91IJBJ1VVWdiM/n6LruNJtNDs3JR3ukIW03SHTHi8iVsbG9I51OG1bW16HVasHQZopDc/JZVgdIQ1o3BmTkEnJXURS/KIpgGAYPkCQJPi0u8uzDKQN0XQPbtgE1MmrHs9nsfSqAEjxCNtHxZHLy4G4smUQgyzL4LzOegDGGp1ucVqsNqKVrpJCM7F4hg6iaZvhqtZrg8XjA4xnAU3XeKLqWaRImoIZeQXVjQO5pYp4xNVirsR1erxer2O4yfa227WCwhtWoJmn7m0h270NxmemFW4706zMm8GCgxBGEASCfhnukIW03iFdQnOPz0LNKp3362JqQzSw4u2LXBe+Bs3xD+/oc1NxN55RiC9fOme0LEQiRf2rBzaKEeJJ37ZWTVunBeGN2WmQjg/DeLTVP89nzAive2dMwlo9bpFVC2xWMZr+A720FVn88fAUb3wDMOjyN7YNc6TvUSHQ4AH6TOUdLL7em68UtWPsJqxgTpgeiLu1EBt1R+Me/mF7CQPTfAgwAGxY2vOTrR3oAAAAASUVORK5CYII="}
+
+
+use then the curl tool to execute a request to the webhook.
+
+
+#!/bin/bash
+curl -H "Content-Type:application/json" -X POST -d @testRequest.json \
+http://localhost:9000/hooks/test-file-webhook
+
+
+or in a single line, using https://github.com/jpmens/jo to generate the JSON code
+
+jo binary=%filename.zip | curl -H "Content-Type:application/json" -X POST -d @- \
+http://localhost:9000/hooks/test-file-webhook
+
diff --git a/docs/Hook-Rules.md b/docs/Hook-Rules.md
new file mode 100644
index 0000000..32d35d3
--- /dev/null
+++ b/docs/Hook-Rules.md
@@ -0,0 +1,201 @@
+# Hook rules
+
+## And
+*And rule* will evaluate to _true_, if and only if all of the sub rules evaluate to _true_.
+```json
+{
+"and":
+ [
+ {
+ "match":
+ {
+ "type": "value",
+ "value": "refs/heads/master",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ }
+ }
+ },
+ {
+ "match":
+ {
+ "type": "regex",
+ "regex": ".*",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "repository.owner.name"
+ }
+ }
+ }
+ ]
+}
+```
+## Or
+*Or rule* will evaluate to _true_, if any of the sub rules evaluate to _true_.
+```json
+{
+"or":
+ [
+ {
+ "match":
+ {
+ "type": "value",
+ "value": "refs/heads/master",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ }
+ }
+ },
+ {
+ "match":
+ {
+ "type": "value",
+ "value": "refs/heads/development",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ }
+ }
+ }
+ ]
+}
+```
+## Not
+*Not rule* will evaluate to _true_, if and only if the sub rule evaluates to _false_.
+```json
+{
+"not":
+ {
+ "match":
+ {
+ "type": "value",
+ "value": "refs/heads/development",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ }
+ }
+ }
+}
+```
+## Multi-level
+```json
+{
+ "and": [
+ {
+ "match": {
+ "parameter": {
+ "source": "header",
+ "name": "X-Hub-Signature"
+ },
+ "type": "payload-hash-sha1",
+ "secret": "mysecret"
+ }
+ },
+ {
+ "or": [
+ {
+ "match":
+ {
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ },
+ "type": "value",
+ "value": "refs/heads/master"
+ }
+ },
+ {
+ "match":
+ {
+ "parameter":
+ {
+ "source": "header",
+ "name": "X-GitHub-Event"
+ },
+ "type": "value",
+ "value": "ping"
+ }
+ }
+ ]
+ }
+ ]
+}
+```
+## Match
+*Match rule* will evaluate to _true_, if and only if the referenced value in the `parameter` field satisfies the `type`-specific rule.
+
+*Please note:* Due to technical reasons, _number_ and _boolean_ values in the _match rule_ must be wrapped around with a pair of quotes.
+
+There are three different match rules:
+
+### 1. Match value
+```json
+{
+ "match":
+ {
+ "type": "value",
+ "value": "refs/heads/development",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ }
+ }
+}
+```
+
+### 2. Match regex
+For the regex syntax, check out
+```json
+{
+ "match":
+ {
+ "type": "regex",
+ "regex": ".*",
+ "parameter":
+ {
+ "source": "payload",
+ "name": "ref"
+ }
+ }
+}
+```
+
+### 3. Match payload-hash-sha1
+```json
+{
+ "match":
+ {
+ "type": "payload-hash-sha1",
+ "secret": "yoursecret",
+ "parameter":
+ {
+ "source": "header",
+ "name": "X-Hub-Signature"
+ }
+ }
+}
+```
+
+### 4. Match Whitelisted IP range
+
+The IP can be IPv4- or IPv6-formatted, using [CIDR notation](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_blocks). To match a single IP address only, use `/32`.
+
+```json
+{
+ "match":
+ {
+ "type": "ip-whitelist",
+ "ip-range": "192.168.0.1/24"
+ }
+}
+```
\ No newline at end of file
diff --git a/docs/Referencing-Request-Values.md b/docs/Referencing-Request-Values.md
new file mode 100644
index 0000000..6e05566
--- /dev/null
+++ b/docs/Referencing-Request-Values.md
@@ -0,0 +1,90 @@
+# Referencing request values
+There are three types of request values:
+
+1. HTTP Request Header values
+
+ ```json
+ {
+ "source": "header",
+ "name": "Header-Name"
+ }
+ ```
+
+2. HTTP Query parameters
+
+ ```json
+ {
+ "source": "url",
+ "name": "parameter-name"
+ }
+ ```
+
+3. Payload (JSON or form-value encoded)
+ ```json
+ {
+ "source": "payload",
+ "name": "parameter-name"
+ }
+ ```
+
+ *Note:* For JSON encoded payload, you can reference nested values using the dot-notation.
+ For example, if you have following JSON payload
+
+ ```json
+ {
+ "commits": [
+ {
+ "commit": {
+ "id": 1
+ }
+ }, {
+ "commit": {
+ "id": 2
+ }
+ }
+ ]
+ }
+ ```
+
+ You can reference the first commit id as
+
+ ```json
+ {
+ "source": "payload",
+ "name": "commits.0.commit.id"
+ }
+ ```
+
+ If the payload contains a key with the specified name "commits.0.commit.id", then the value of that key has priority over the dot-notation referencing.
+
+If you are referencing values for environment, you can use `envname` property to set the name of the environment variable like so
+```json
+{
+ "source": "url",
+ "name": "q",
+ "envname": "QUERY"
+}
+```
+to get the QUERY environment variable set to the `q` parameter passed in the query string.
+
+# Special cases
+If you want to pass the entire payload as JSON string to your command you can use
+```json
+{
+ "source": "entire-payload"
+}
+```
+
+for headers you can use
+```json
+{
+ "source": "entire-headers"
+}
+```
+
+and for query variables you can use
+```json
+{
+ "source": "entire-query"
+}
+```
\ No newline at end of file
diff --git a/docs/Webhook-Parameters.md b/docs/Webhook-Parameters.md
new file mode 100644
index 0000000..ab51bea
--- /dev/null
+++ b/docs/Webhook-Parameters.md
@@ -0,0 +1,38 @@
+# Webhook parameters
+```
+Usage of webhook:
+ -cert string
+ path to the HTTPS certificate pem file (default "cert.pem")
+ -header value
+ response header to return, specified in format name=value, use multiple times to set multiple headers
+ -hooks value
+ path to the json file containing defined hooks the webhook should serve, use multiple times to load from different files
+ -hotreload
+ watch hooks file for changes and reload them automatically
+ -ip string
+ ip the webhook should serve hooks on (default "0.0.0.0")
+ -key string
+ path to the HTTPS certificate private key pem file (default "key.pem")
+ -nopanic
+ do not panic if hooks cannot be loaded when webhook is not running in verbose mode
+ -port int
+ port the webhook should serve hooks on (default 9000)
+ -secure
+ use HTTPS instead of HTTP
+ -template
+ parse hooks file as a Go template
+ -urlprefix string
+ url prefix to use for served hooks (protocol://yourserver:port/PREFIX/:hook-id) (default "hooks")
+ -verbose
+ show verbose output
+ -version
+ display webhook version and quit
+```
+
+Use any of the above specified flags to override their default behavior.
+
+# Live reloading hooks
+If you are running an OS that supports USR1 signal, you can use it to trigger hooks reload from hooks file, without restarting the webhook instance.
+```bash
+kill -USR1 webhookpid
+```
\ No newline at end of file