如何在流明框架中获取中间件上的当前路由? [英] How to get the current route on middleware in lumen framework?

查看:81
本文介绍了如何在流明框架中获取中间件上的当前路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用lumen开发了API应用程序.并进行访问权限控制.我想在中间件中获取当前路由.但是,我总是在以下方面无效:

I have develop the API application using lumen. And for the access permission control. I want to get the current route in middleware. But, I always get null on:

   $route = $request->route();

我已经在>可以通过Lumen在中间件中获取当前路线信息?,它使用routeMiddleware和调度程序.但是它仍然返回null.如何在中间件上获取当前路由?

I already try the way on the Can I get current route information in middleware with Lumen? which using the routeMiddleware and dispatcher. But it's still return null. How could I get the current route on middleware?

非常感谢..

推荐答案

请更新您的流明值...一切正常,没有问题

Please update your Lumen... Everything works with no issues

namespace App\Http\Middleware;

public function handle($request, Closure $next)
{
    $route = $request->route();
    $path = $request->getPathInfo();

    // your code here
    return $next($request);
}

这篇关于如何在流明框架中获取中间件上的当前路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆