Skip to content

Commit 7aa5495

Browse files
Limit scope of default route handler (#2831)
The current default route handler was initially conceived as a way to integrate Laravel into the existing routing system. This route handler only applies to a handful of legacy API routes at this point, falling through with a 404 otherwise. This PR limits the scope of the default route handler to only apply to routes under `/api`, using Laravel's default route handler for the rest of the routes. I also changed the visibility of most of the functions in the file to better reflect their purpose.
1 parent 25548be commit 7aa5495

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

app/Http/Controllers/CDash.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __invoke(Request $request)
6666
/**
6767
* Determines if the file being requested is in the CDash filesystem
6868
*/
69-
public function isValidRequest(): bool
69+
protected function isValidRequest(): bool
7070
{
7171
$valid = false;
7272
$path = $this->getPath();
@@ -80,7 +80,7 @@ public function isValidRequest(): bool
8080
/**
8181
* Determines if the request is a request for a CDash api endpoint
8282
*/
83-
public function isApiRequest(): bool
83+
protected function isApiRequest(): bool
8484
{
8585
$path = $this->getPath();
8686
return str_starts_with($path, 'api/');
@@ -89,7 +89,7 @@ public function isApiRequest(): bool
8989
/**
9090
* Processes the CDash file for a given request
9191
*/
92-
public function getRequestContents()
92+
protected function getRequestContents()
9393
{
9494
$file = $this->getAbsolutePath();
9595
chdir($this->disk->path(''));
@@ -111,7 +111,7 @@ public function getRequestContents()
111111
*
112112
* @return ResponseFactory|JsonResponse|Response|\Symfony\Component\HttpFoundation\Response
113113
*/
114-
public function handleApiRequest()
114+
protected function handleApiRequest()
115115
{
116116
$json = $this->getRequestContents();
117117
$status = http_response_code(); // this should be empty if not previously set
@@ -136,7 +136,7 @@ public function handleApiRequest()
136136
/**
137137
* Returns the path of the request with consideration given to the root path
138138
*/
139-
public function getPath(): string
139+
protected function getPath(): string
140140
{
141141
if (!$this->path) {
142142
$path = $this->request->path();
@@ -146,7 +146,7 @@ public function getPath(): string
146146
return $this->path;
147147
}
148148

149-
public function getAbsolutePath(): string
149+
protected function getAbsolutePath(): string
150150
{
151151
$path = $this->getPath();
152152
$file = $this->disk->path($path);

routes/web.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,3 @@
271271
Route::get('/monitor.php', fn () => redirect('/monitor', 301));
272272
});
273273
});
274-
275-
// this *MUST* be the last route in the file
276-
Route::any('{url}', 'CDash')->where('url', '.*');

0 commit comments

Comments
 (0)