duan0514324 2019-02-04 14:04
浏览 79

内核中的Auth声明和laravel中的路由无法正常工作

I had used JWT middleware for my one of the application. My code is worked after some research but I have not understood the actual reason behind that.

I had introduced auth in kernel.php below is my code.

namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
    ....
    ....
    protected $routeMiddleware = [
        ....
        'jwt-auth' => \App\Http\Middleware\jwtMiddleware::class,
    ];

i am using 'jwt-auth' as the jwt middleware.

but when using in routing. tried to use like jwt-auth but It will not work. then after some research used jwt.auth then working correctly. so why it's used by the . not -. logically we make auth with name jwt-auth.

Any help or idea will be appreciated.

Route::group(['middleware' => ['jwt.auth','api-header']], function () {

    // all routes to protected resources are registered here  
    Route::get('users/list', function(){
        $users = App\User::all();

        $response = ['success'=>true, 'data'=>$users];
        return response()->json($response, 201);
    });
});

The same thing I was used for different middleware for including API header with - but it will work same as the kernel alias.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 一道python难题
    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度