This repository was archived by the owner on Apr 13, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ class LockingMiddleware
3131 */
3232 protected $ locker ;
3333
34+ /**
35+ * The URIs that should be excluded.
36+ *
37+ * @var string[]
38+ */
39+ protected $ except = [];
40+
3441 /**
3542 * Create a new locking middleware instance.
3643 *
@@ -55,7 +62,7 @@ public function __construct(Locker $locker)
5562 */
5663 public function handle (Request $ request , Closure $ next )
5764 {
58- if ($ request ->isMethodSafe ()) {
65+ if ($ request ->isMethodSafe () || $ this -> shouldPassThrough ( $ request ) ) {
5966 return $ next ($ request );
6067 }
6168
@@ -73,4 +80,26 @@ public function handle(Request $request, Closure $next)
7380
7481 return $ response ;
7582 }
83+
84+ /**
85+ * Determine if the request has a URI that should pass through.
86+ *
87+ * @param \Illuminate\Http\Request $request
88+ *
89+ * @return bool
90+ */
91+ protected function shouldPassThrough (Request $ request )
92+ {
93+ foreach ($ this ->except as $ except ) {
94+ if ($ except !== '/ ' ) {
95+ $ except = trim ($ except , '/ ' );
96+ }
97+
98+ if ($ request ->is ($ except )) {
99+ return true ;
100+ }
101+ }
102+
103+ return false ;
104+ }
76105}
You can’t perform that action at this time.
0 commit comments