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.