softonic/laravel-middleware-request-id 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

softonic/laravel-middleware-request-id

最新稳定版本:v2.1.0

Composer 安装命令:

composer require softonic/laravel-middleware-request-id

包简介

Middleware for Laravel Framework to add the X-Request-ID header in the requests and responses.

README 文档

README

Build Status

Install

$ composer require softonic/laravel-middleware-request-id

Usage

For all routes or a specific group

Add Softonic\Laravel\Middleware\RequestId::class in App\Http\Kernel.

For all routes:

protected $middleware = [
    \Softonic\Laravel\Middleware\RequestId::class,
    ....
]

Specific group:

// Example for WEB group
protected $middlewareGroups = [
        'web' => [
			\Softonic\Laravel\Middleware\RequestId::class,
			...
        ],

        'api' => [
            ...
        ],
    ];

For a specific route

Register the middleware as a route middleware in App\Http\Kernel.

    protected $routeMiddleware = [
		...
		'request-id' => Softonic\Laravel\Middleware\RequestId::class,
    ];

then, use it in your routes file, for example in routes\web.php

Route::get('route', function() {})->middleware('request-id');

Extra

If you need to have the X-Request-Id ASAP, you can modify \App\Providers\AppServiceProvider::boot adding $_SERVER['HTTP_X_REQUEST_ID'] ??= \Ramsey\Uuid\Uuid::uuid4()->toString();. This is going to allow you to use the X-Request-ID in the framework booting to for example customize monolog or in console executions.

统计信息

  • 总下载量: 104.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 6
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2017-02-08