Commit fef0efb9 by 朱继来

temp3

parent f7d0c024
...@@ -28,6 +28,7 @@ class Kernel extends HttpKernel ...@@ -28,6 +28,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\CheckLogin::class, \App\Http\Middleware\CheckLogin::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class, \Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\Check::class,
\App\Http\Middleware\CheckRequest::class, \App\Http\Middleware\CheckRequest::class,
], ],
......
<?php
namespace App\Http\Middleware;
use Closure;
use Session;
class Check
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
Session::put('pid', uniqid('order_', true));
// if ($request->ajax() && $request->isMethod('post')) {
// }
return $next($request);
}
}
...@@ -5,6 +5,7 @@ namespace App\Http\Middleware; ...@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use Cookie; use Cookie;
use Session;
class CheckRequest class CheckRequest
{ {
...@@ -27,6 +28,7 @@ class CheckRequest ...@@ -27,6 +28,7 @@ class CheckRequest
Redis::incr($key); // 计数器 Redis::incr($key); // 计数器
$count = Redis::get($key); $count = Redis::get($key);
$pid = Session::get('pid');
dump($count); dump($count);
if ($count > 1) return abort(501, '请勿重新提交!'); // 501服务器不支持当前请求 if ($count > 1) return abort(501, '请勿重新提交!'); // 501服务器不支持当前请求
...@@ -52,13 +54,6 @@ dump($count); ...@@ -52,13 +54,6 @@ dump($count);
return $next($request); return $next($request);
} }
public function terminate($request, $response)
{
$key = $this->getFormKey($request);
dump('响应信息');
// Redis::del($key);
}
public function getFormKey($request) public function getFormKey($request)
{ {
$action = $request->route()->getAction(); // 获取路由信息 $action = $request->route()->getAction(); // 获取路由信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment