You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ go build
78
78
79
79
### Basic Example
80
80
81
-
Create a `hooks.json` file (or `hooks.yaml`for YAML format) to define your webhooks:
81
+
By default, webhook scans config files from the `./hooks` directory. Create `./hooks/hooks.yaml`(or `./hooks/hooks.json`) to define your webhooks:
82
82
83
83
**Example: Simple Deployment Hook**
84
84
@@ -100,10 +100,10 @@ If you prefer YAML, the equivalent `hooks.yaml` file would look like this:
100
100
command-working-directory: "/var/webhook"
101
101
```
102
102
103
-
### Running WebHook
103
+
### Running WebHook (default directory mode)
104
104
105
105
```bash
106
-
./webhook -hooks hooks.json -verbose
106
+
./webhook -verbose
107
107
```
108
108
109
109
The server will start on port `9000` by default. Your hook will be available at:
@@ -112,6 +112,12 @@ The server will start on port `9000` by default. Your hook will be available at:
112
112
http://yourserver:9000/hooks/redeploy-webhook
113
113
```
114
114
115
+
Single-file mode is still supported when explicitly set:
116
+
117
+
```bash
118
+
./webhook -hooks hooks.json -verbose
119
+
```
120
+
115
121
### Securing Your Hooks
116
122
117
123
**Important**: The example above has no authentication. Always use trigger rules in production!
@@ -148,7 +154,7 @@ For more security options, see:
148
154
149
155
-**Form Data Support**: Parse multipart form data and file uploads - see [Form Data](docs/en-US/Referencing-Request-Values.md)
150
156
-**Template Support**: Use Go templates in configuration files with `-template` flag - see [Templates](docs/en-US/Templates.md)
151
-
-**Config UI**: Same binary, behavior by flags. Enable config generator Web UI with `-config-ui` (recommend debugging or intranet only). Config-ui-only: `go run . -config-ui` (no `-hooks`, default port 9080); or mount on webhook server with `-hooks` and `-config-ui`. Use `-config-ui-path`to change the path (trailing slash is normalized). With `-hooks-dir`, the UI can save generated configs into that directory. The `-urlprefix` value is used for the call URL shown in the UI. See [Webhook Parameters](docs/en-US/Webhook-Parameters.md) and [Config UI](cmd/README.md).
157
+
-**Config UI**: Same binary, behavior by flags. Enable config generator Web UI with `-config-ui` (recommend debugging or intranet only). It runs on the same server port (default `9000`) and can be mounted with `-config-ui-path` (trailing slash normalized). In directory mode (default `./hooks` or explicit `-hooks-dir`), the UI can save generated configs directly to that directory and you can validate by calling the generated endpoint immediately after save. In explicit single-file mode (`-hooks`), generation/download still works but save-to-directory is not exposed. The `-urlprefix` value is used for the call URL shown in the UI. See [Webhook Parameters](docs/en-US/Webhook-Parameters.md) and [Config UI](cmd/README.md).
152
158
-**HTTPS**: Use a reverse proxy (nginx, Traefik, Caddy) for HTTPS support
153
159
-**CORS**: Set custom headers including CORS headers with `-header name=value`
154
160
-**Hot Reload**: Update configurations without restarting using `-hotreload` or `kill -USR1`
@@ -159,7 +165,7 @@ For more examples and use cases, check out [Hook Examples](docs/en-US/Hook-Examp
Copy file name to clipboardExpand all lines: SECURITY.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ Webhook includes several security features to help prevent command injection att
32
32
- Set appropriate limits for argument length and count
33
33
- Regularly review and update your whitelist
34
34
- Never enable `--allow-auto-chmod` in production (it's a security risk)
35
-
- Do not enable `--openapi` or `--config-ui` on publicly reachable servers (they have no authentication; use only for debugging or intranet). Config UI can run as config-ui-only (`-config-ui` without `-hooks`) or mounted on the webhook server; in both cases restrict access.
35
+
- Do not enable `--openapi` or `--config-ui` on publicly reachable servers (they have no authentication; use only for debugging or intranet). Config UI is mounted on the webhook server; restrict access with firewall/reverse proxy.
36
36
37
37
For more details, see the [Webhook Parameters (English)](docs/en-US/Webhook-Parameters.md) or [配置参数 (中文)](docs/zh-CN/Webhook-Parameters.md).
**Availability:** Config UI is available in two ways: (1) Config-ui-only mode: `-config-ui`without `-hooks` (default port 9080); (2) Mounted on webhook server: `-hooks` with `-config-ui` (path via `-config-ui-path`). Not exposed by default; recommend use only for debugging or intranet.
114
+
**Availability:** Config UI is mounted on the webhook server when `-config-ui`is enabled (path via `-config-ui-path`, default `/config-ui`). Not exposed by default; recommend use only for debugging or intranet.
115
115
116
-
**Description:** Web UI and API for generating hook configuration (YAML/JSON) and call examples. Same functionality as config-ui-only mode (run with `-config-ui` and no `-hooks`).
116
+
**Description:** Web UI and API for generating hook configuration (YAML/JSON) and call examples.
117
117
118
118
-**GET**`{config-ui-path}` or `{config-ui-path}/`: Returns the config generator HTML page.
-**POST**`{config-ui-path}/api/generate`: Accepts JSON body with form fields (e.g. `id`, `execute-command`, `response-message`, `trigger-rule`). Returns `{ "yaml", "json", "callUrl", "curlExample" }` on success, or `{ "error": "..." }` with 4xx on validation error.
121
-
-**GET**`{config-ui-path}/api/capabilities`: Returns `{ "saveToDir": true|false }`. When `true`, the UI shows a "Save to directory" option (requires`-hooks-dir`).
122
-
-**POST**`{config-ui-path}/api/save`: Writes generated config to the directory set by `-hooks-dir`. Body: `{ "filename": "name.yaml", "content": "..."}`. Returns `{ "ok": "<absolute-path>" }` on success, or `{ "error": "..." }` with 4xx when disabled or invalid (e.g. path traversal). Filename must have extension `.json`, `.yaml`, or `.yml`.
121
+
-**GET**`{config-ui-path}/api/capabilities`: Returns `{ "saveToDir": true|false }`. When `true`, the UI shows a "Save to directory" option (directory mode: default `./hooks` or explicit`-hooks-dir`).
122
+
-**POST**`{config-ui-path}/api/save`: Writes generated config to hooks directory. Body: `{ "filename": "name.yaml", "content": "...", "format": "yaml|json" }`. Returns `{ "ok": "<absolute-path>" }` on success, or `{ "error": "..." }` with 4xx when disabled or invalid (e.g. path traversal, format mismatch, invalid hook config). Filename must have extension `.json`, `.yaml`, or `.yml`.
123
123
124
124
**Example:**
125
125
```bash
126
-
# Config-ui-only mode (default port 9080)
126
+
#Enable Config UI on webhook server (default port 9000)
127
127
./webhook -config-ui
128
-
# Open http://localhost:9080 in a browser
129
-
130
-
# Or mount Config UI on the webhook server
131
-
./webhook -hooks hooks.json -config-ui
132
128
# Open http://localhost:9000/config-ui in a browser
0 commit comments