|
| 1 | +# Configuration |
| 2 | + |
| 3 | +This document describes how you can configure your **Hooks** server to run. |
| 4 | + |
| 5 | +There are two type of configurations: |
| 6 | + |
| 7 | +- **Global Options** - These options are set in the `hooks.yaml` file and apply to the entire server. |
| 8 | +- **Endpoint Options** - These options are set in each endpoint's configuration file and apply only to that specific endpoint. |
| 9 | + |
| 10 | +## Global Options |
| 11 | + |
| 12 | +### `endpoints_dir` |
| 13 | + |
| 14 | +The directory containing endpoint configuration files. Each file in this directory defines a specific webhook endpoint and its configuration. |
| 15 | + |
| 16 | +**Example:** `./config/endpoints` |
| 17 | + |
| 18 | +### `handler_plugin_dir` |
| 19 | + |
| 20 | +The directory where the handler plugins are located. Handlers are responsible for processing incoming webhook requests. A handler plugin directory should contain one or more handlers that are Ruby files. For more information on handler plugins, see the [Handler Plugins documentation](./handler_plugins.md). |
| 21 | + |
| 22 | +**Example:** `./plugins/handlers` |
| 23 | + |
| 24 | +### `auth_plugin_dir` |
| 25 | + |
| 26 | +The directory where the authentication plugins are located. Authentication plugins are responsible for validating incoming webhook requests before they are processed by handlers. For more information on authentication plugins, see the [Auth Plugins documentation](./auth_plugins.md). |
| 27 | + |
| 28 | +**Example:** `./plugins/auth` |
| 29 | + |
| 30 | +### `lifecycle_plugin_dir` |
| 31 | + |
| 32 | +The directory where the lifecycle plugins are located. Lifecycle plugins allow you to hook into various stages of the webhook processing lifecycle. For more information on lifecycle plugins, see the [Lifecycle Plugins documentation](./lifecycle_plugins.md). |
| 33 | + |
| 34 | +**Example:** `./plugins/lifecycle` |
| 35 | + |
| 36 | +### `instruments_plugin_dir` |
| 37 | + |
| 38 | +The directory where the instrumentation plugins are located. Instrumentation plugins are responsible for collecting metrics and monitoring data from the webhook server. For more information on instrumentation plugins, see the [Instrument Plugins documentation](./instrument_plugins.md). |
| 39 | + |
| 40 | +**Example:** `./plugins/instruments` |
| 41 | + |
| 42 | +### `log_level` |
| 43 | + |
| 44 | +Sets the logging level for the server. Valid values are `debug`, `info`, `warn`, `error`, and `fatal`. |
| 45 | + |
| 46 | +**Default:** `info` |
| 47 | +**Example:** `debug` |
| 48 | + |
| 49 | +### `request_limit` |
| 50 | + |
| 51 | +The maximum size (in bytes) allowed for incoming request bodies. This helps prevent memory exhaustion from extremely large payloads. |
| 52 | + |
| 53 | +**Default:** `1048576` (1MB) |
| 54 | +**Example:** `1048576` |
| 55 | + |
| 56 | +### `request_timeout` |
| 57 | + |
| 58 | +The maximum time (in seconds) to wait for an incoming request to complete before timing out. |
| 59 | + |
| 60 | +**Default:** `30` |
| 61 | +**Example:** `15` |
| 62 | + |
| 63 | +### `root_path` |
| 64 | + |
| 65 | +The base path for all webhook endpoints. All endpoint routes will be prefixed with this path. |
| 66 | + |
| 67 | +**Default:** `/webhooks` |
| 68 | +**Example:** `/webhooks` |
| 69 | + |
| 70 | +### `health_path` |
| 71 | + |
| 72 | +The path for the health check endpoint. This endpoint returns the server's health status. |
| 73 | + |
| 74 | +**Default:** `/health` |
| 75 | +**Example:** `/health` |
| 76 | + |
| 77 | +### `version_path` |
| 78 | + |
| 79 | +The path for the version endpoint. This endpoint returns the server's version information. |
| 80 | + |
| 81 | +**Default:** `/version` |
| 82 | +**Example:** `/version` |
| 83 | + |
| 84 | +### `environment` |
| 85 | + |
| 86 | +Specifies the runtime environment for the server. This can affect logging, error handling, and other behaviors. Warning - running in development mode will return full stack traces in error responses. |
| 87 | + |
| 88 | +**Default:** `production` |
| 89 | +**Example:** `development` |
| 90 | + |
| 91 | +### `use_catchall_route` |
| 92 | + |
| 93 | +When set to `true`, enables a catch-all route that will handle requests to unknown endpoints. When `false`, requests to undefined endpoints will return a 404 error. |
| 94 | + |
| 95 | +**Default:** `false` |
| 96 | +**Example:** `false` |
| 97 | + |
| 98 | +## Endpoint Options |
| 99 | + |
| 100 | +### `path` |
| 101 | + |
| 102 | +The path for the webhook endpoint. This is the URL that clients will use to send webhook requests. It should be unique across all endpoints. Simply stating the path will create a route like `/webhooks/{path}`. |
| 103 | + |
| 104 | +**Example:** `/github` will create the route `/webhooks/github` if `root_path` is set to `/webhooks`. |
| 105 | + |
| 106 | +### `handler` |
| 107 | + |
| 108 | +The name of the Ruby class that will handle the incoming webhook requests for this endpoint. The handler class should be defined in the `handler_plugin_dir`. For example, if you have a handler class named `GithubHandler`, you would specify it as follows: |
| 109 | + |
| 110 | +```yaml |
| 111 | +handler: GithubHandler |
| 112 | +``` |
| 113 | +
|
| 114 | +> For readability, you should use CamelCase for handler names, as they are Ruby classes. You should then name the file in the `handler_plugin_dir` as `github_handler.rb`. |
| 115 | + |
| 116 | +### `auth` |
| 117 | + |
| 118 | +Authentication configuration for the endpoint. This section defines how incoming requests will be authenticated before being processed by the handler. |
| 119 | + |
| 120 | +Each auth plugin can have its own configuration options. The `type` field is required though, and it specifies which authentication plugin to use. The available types are defined in the `auth_plugin_dir`. |
| 121 | + |
| 122 | +**Example:** |
| 123 | + |
| 124 | +```yaml |
| 125 | +auth: |
| 126 | + type: hmac |
| 127 | + secret_env_key: GITHUB_WEBHOOK_SECRET |
| 128 | + header: X-Hub-Signature-256 |
| 129 | + algorithm: sha256 |
| 130 | + format: "algorithm=signature" # produces "sha256=abc123..." |
| 131 | +``` |
| 132 | + |
| 133 | +### `opts` |
| 134 | + |
| 135 | +Additional options for the endpoint. This section can include any custom options that the handler may require. The options are specific to the handler and can vary based on its implementation. You can put anything your heart desires here. |
0 commit comments