国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

救救救小白求助 JWTAuth::process()

Allen_12138

問題描述

app\middleware\JWTAuth::process(): Return value must be of type support\Response, Webman\Http\Response returned
已指明返回類型,仍是報錯

報錯信息

app\\middleware\\JWTAuth::process(): Return value must be of type support\\Response, Webman\\Http\\Response returned

截圖報錯信息里報錯文件相關(guān)代碼

截圖
中間件
截圖
截圖

686 4 0
4個回答

Gin

中間內(nèi) 那倆換成
use Webman\Http\Request;
use Webman\Http\Response;

  • 暫無評論
Tinywan

一個很簡單的插件竟然被用的這么復(fù)雜

  • 暫無評論
Allen_12138

未解決,換了一種取值方式,不能直接userInfo取值了
$token = JwtToken::getExtend();

  • 暫無評論
Tinywan

中間件正確使用方式

declare(strict_types=1);

namespace app\middleware;

use Tinywan\ExceptionHandler\Exception\ForbiddenHttpException;
use Tinywan\Jwt\JwtToken;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;

class AuthorizationMiddleware implements MiddlewareInterface
{
    /**
     * @param Request $request
     * @param callable $handler
     * @return Response
     * @throws ForbiddenHttpException
     */
    public function process(Request $request, callable $handler): Response
    {
        $request->userId = JwtToken::getCurrentId();
        if (0 === $request->userId) {
            throw new ForbiddenHttpException();
        }
        return $handler($request);
    }
}
  • 暫無評論
??