@@ -25,6 +25,13 @@ class InjectDebugbar
25
25
*/
26
26
protected $ debugbar ;
27
27
28
+ /**
29
+ * The URIs that should be excluded.
30
+ *
31
+ * @var array
32
+ */
33
+ protected $ except = [];
34
+
28
35
/**
29
36
* Create a new middleware instance.
30
37
*
@@ -35,6 +42,7 @@ public function __construct(Container $container, LaravelDebugbar $debugbar)
35
42
{
36
43
$ this ->container = $ container ;
37
44
$ this ->debugbar = $ debugbar ;
45
+ $ this ->except = config ('debugbar.except ' ) ?: [];
38
46
}
39
47
40
48
/**
@@ -46,7 +54,7 @@ public function __construct(Container $container, LaravelDebugbar $debugbar)
46
54
*/
47
55
public function handle ($ request , Closure $ next )
48
56
{
49
- if (!$ this ->debugbar ->isEnabled ()) {
57
+ if (!$ this ->debugbar ->isEnabled () || $ this -> inExceptArray ( $ request ) ) {
50
58
return $ next ($ request );
51
59
}
52
60
@@ -91,4 +99,25 @@ protected function handleException($passable, Exception $e)
91
99
92
100
return $ handler ->render ($ passable , $ e );
93
101
}
102
+
103
+ /**
104
+ * Determine if the request has a URI that should be ignored.
105
+ *
106
+ * @param \Illuminate\Http\Request $request
107
+ * @return bool
108
+ */
109
+ protected function inExceptArray ($ request )
110
+ {
111
+ foreach ($ this ->except as $ except ) {
112
+ if ($ except !== '/ ' ) {
113
+ $ except = trim ($ except , '/ ' );
114
+ }
115
+
116
+ if ($ request ->is ($ except )) {
117
+ return true ;
118
+ }
119
+ }
120
+
121
+ return false ;
122
+ }
94
123
}
0 commit comments