implemented server side webhook request side debugging. Closes #251
This commit is contained in:
32
FAQ.md
32
FAQ.md
@@ -146,22 +146,22 @@ $ docker exec -ti watchstate console system:env
|
||||
|
||||
These environment variables relates to the tool itself, you can load them via the recommended methods.
|
||||
|
||||
| Key | Type | Description | Default |
|
||||
|--------------------------|---------|-------------------------------------------------------------------------------|--------------------|
|
||||
| WS_DATA_PATH | string | Where to store main data. (config, db). | `${BASE_PATH}/var` |
|
||||
| WS_TMP_DIR | string | Where to store temp data. (logs, cache) | `${WS_DATA_PATH}` |
|
||||
| WS_TZ | string | Set timezone. | `UTC` |
|
||||
| WS_CRON_{TASK} | bool | Enable {task} task. Value casted to bool. | `false` |
|
||||
| WS_CRON_{TASK}_AT | string | When to run {task} task. Valid Cron Expression Expected. | `*/1 * * * *` |
|
||||
| WS_CRON_{TASK}_ARGS | string | Flags to pass to the {task} command. | `-v` |
|
||||
| WS_LOGS_CONTEXT | bool | Add context to console output messages. | `false` |
|
||||
| WS_LOGGER_FILE_ENABLE | bool | Save logs to file. | `true` |
|
||||
| WS_LOGGER_FILE_LEVEL | string | File Logger Level. | `ERROR` |
|
||||
| WS_WEBHOOK_DEBUG | bool | If enabled, allow dumping request/webhook using `rdump` & `wdump` parameters. | `false` |
|
||||
| WS_EPISODES_DISABLE_GUID | bool | Disable external id parsing for episodes and rely on relative ids. | `true` |
|
||||
| WS_TRUST_PROXY | bool | Trust `WS_TRUST_HEADER` ip. Value casted to bool. | `false` |
|
||||
| WS_TRUST_HEADER | string | Which header contain user true IP. | `X-Forwarded-For` |
|
||||
| WS_LIBRARY_SEGMENT | integer | Paginate backend library items request. Per request get total X number. | `1000` |
|
||||
| Key | Type | Description | Default |
|
||||
|--------------------------|---------|-------------------------------------------------------------------------|--------------------|
|
||||
| WS_DATA_PATH | string | Where to store main data. (config, db). | `${BASE_PATH}/var` |
|
||||
| WS_TMP_DIR | string | Where to store temp data. (logs, cache) | `${WS_DATA_PATH}` |
|
||||
| WS_TZ | string | Set timezone. | `UTC` |
|
||||
| WS_CRON_{TASK} | bool | Enable {task} task. Value casted to bool. | `false` |
|
||||
| WS_CRON_{TASK}_AT | string | When to run {task} task. Valid Cron Expression Expected. | `*/1 * * * *` |
|
||||
| WS_CRON_{TASK}_ARGS | string | Flags to pass to the {task} command. | `-v` |
|
||||
| WS_LOGS_CONTEXT | bool | Add context to console output messages. | `false` |
|
||||
| WS_LOGGER_FILE_ENABLE | bool | Save logs to file. | `true` |
|
||||
| WS_LOGGER_FILE_LEVEL | string | File Logger Level. | `ERROR` |
|
||||
| WS_WEBHOOK_DUMP_REQUEST | bool | If enabled, will dump all received requests. | `false` |
|
||||
| WS_EPISODES_DISABLE_GUID | bool | Disable external id parsing for episodes and rely on relative ids. | `true` |
|
||||
| WS_TRUST_PROXY | bool | Trust `WS_TRUST_HEADER` ip. Value casted to bool. | `false` |
|
||||
| WS_TRUST_HEADER | string | Which header contain user true IP. | `X-Forwarded-For` |
|
||||
| WS_LIBRARY_SEGMENT | integer | Paginate backend library items request. Per request get total X number. | `1000` |
|
||||
|
||||
**Note**: for environment variables that has `{TASK}` tag, you **MUST** replace it with one
|
||||
of `IMPORT`, `EXPORT`, `PUSH`, `BACKUP`, `PRUNE`, `INDEXES`, `REQUESTS`. To see tasks active settings run
|
||||
|
||||
@@ -16,5 +16,6 @@ return [
|
||||
'webhook.match.user',
|
||||
'webhook.match.uuid',
|
||||
'webhook.token',
|
||||
'options.ignore'
|
||||
'options.ignore',
|
||||
'options.DUMP_PAYLOAD',
|
||||
];
|
||||
|
||||
@@ -76,7 +76,8 @@ return (function () {
|
||||
$config['webhook'] = [
|
||||
'logfile' => ag($config, 'tmpDir') . '/logs/access.' . $logDateFormat . '.log',
|
||||
'debug' => (bool)env('WS_WEBHOOK_DEBUG', false),
|
||||
'tokenLength' => 16,
|
||||
'dumpRequest' => (bool)env('WS_WEBHOOK_DUMP_REQUEST', false),
|
||||
'tokenLength' => (int)env('WS_WEBHOOK_TOKEN_LENGTH', 16),
|
||||
];
|
||||
|
||||
$config['mapper'] = [
|
||||
|
||||
@@ -167,15 +167,12 @@ final class Initializer
|
||||
$httpException = (true === ($e instanceof HttpException));
|
||||
|
||||
if (false === $httpException || $e->getCode() !== 200) {
|
||||
Container::get(LoggerInterface::class)->error(
|
||||
$e->getMessage(),
|
||||
[
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'trace' => $e->getTrace(),
|
||||
]
|
||||
);
|
||||
Container::get(LoggerInterface::class)->error($e->getMessage(), [
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'kind' => get_class($e),
|
||||
'trace' => $e->getTrace(),
|
||||
]);
|
||||
}
|
||||
|
||||
$response = new Response(
|
||||
@@ -205,7 +202,7 @@ final class Initializer
|
||||
}
|
||||
|
||||
// -- Save request payload.
|
||||
if (true === Config::get('webhook.debug') && true === (bool)ag($realRequest->getQueryParams(), 'rdump')) {
|
||||
if (true === Config::get('webhook.dumpRequest')) {
|
||||
saveRequestPayload($realRequest);
|
||||
}
|
||||
|
||||
@@ -326,7 +323,7 @@ final class Initializer
|
||||
$entity = $class->parseWebhook($request);
|
||||
|
||||
// -- Dump Webhook context.
|
||||
if (true === Config::get('webhook.debug') && true === (bool)ag($request->getQueryParams(), 'wdump')) {
|
||||
if (true === (bool)ag($backend, 'options.' . Options::DUMP_PAYLOAD)) {
|
||||
saveWebhookPayload($entity, $request);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ final class Options
|
||||
public const DISABLE_GUID = 'DISABLE_GUID';
|
||||
public const LIBRARY_SEGMENT = 'LIBRARY_SEGMENT';
|
||||
public const STATE_UPDATE_EVENT = 'STATE_UPDATE_EVENT';
|
||||
public const DUMP_PAYLOAD = 'DUMP_PAYLOAD';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user