bekand/telescope-request-track
最新稳定版本:v1.0.2
Composer 安装命令:
composer require bekand/telescope-request-track
包简介
Automatically attach request identifiers to Laravel JSON responses and Telescope request entries.
README 文档
README
Automatically attach a Telescope-compatible request identifier to every JSON response and propagate it via headers.
Installation
composer require bekand/telescope-request-track
The package registers itself automatically thanks to Laravel's package auto-discovery.
Configuration
Publish the configuration to customise header names, JSON keys, or disable the middleware globally.
php artisan vendor:publish --tag=telescope-track-config
Available options (see config/telescope-track.php):
enabled(bool): Toggle the middleware globally (defaulttrue).show_in_json(bool): Control whether the request ID is appended to JSON payloads (defaulttrue).key(string): JSON key added to responses (defaultrequest_id).header(string): Header used for propagation (defaultX-Request-Id).routes(array): Middleware groups that should receive the request ID middleware (default['api', 'web']).except(array): URI patterns (same semantics as$request->is()) that should not receive a request ID.
Usage
The middleware is prepended globally, so every JSON response automatically gains a request identifier. Responses that already define the configured JSON key are respected.
If a response body is a JSON list, it's wrapped into a structure like:
{
"data": [1, 2, 3],
"request_id": "..."
}
Skipping specific routes
Wrap routes with the provided SkipRequestId middleware to bypass augmentation:
use BekAnd\TelescopeRequestTrack\Middleware\SkipRequestId; Route::get('/health', function () { return response()->json(['status' => 'ok']); })->middleware(SkipRequestId::class);
Telescope integration
When laravel/telescope is installed, the package tags request entries with the request identifier so you can filter them easily:
request-id: <value>
Testing
composer test
License
Released under the MIT License.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-30