Skip to content

Commit 73401c8

Browse files
authored
Merge pull request #201 from aroskanalen/hotfix/2.0.1
1137 - Add /v1 - /v2 redirect controller
2 parents b0f5963 + d65299a commit 73401c8

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [2.0.1] - 2024-04-09
8+
9+
- [#201](https://github.com/os2display/display-api-service/pull/201)
10+
- Add /v1 - /v2 redirect controller
11+
712
## [2.0.0] - 2024-04-09
813

914
- [#199](https://github.com/os2display/display-api-service/pull/199)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Controller;
6+
7+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8+
use Symfony\Component\HttpFoundation\RedirectResponse;
9+
use Symfony\Component\Routing\Attribute\Route;
10+
11+
class ApiV1RedirectController extends AbstractController
12+
{
13+
#[Route('/v1/{endpoint}', name: 'app_api_v1_redirect', requirements: ['endpoint' => '.+'], defaults: ['endpoint' => null], methods: ['GET'])]
14+
public function index(string $endpoint): RedirectResponse
15+
{
16+
return $this->redirect('/v2/'.$endpoint, 301);
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Tests\Controller;
6+
7+
use App\Tests\AbstractBaseApiTestCase;
8+
9+
class ApiV1RedirectControllerTest extends AbstractBaseApiTestCase
10+
{
11+
public function testIndex()
12+
{
13+
$client = $this->getAuthenticatedClient('ROLE_ADMIN');
14+
$crawler = $client->request('GET', '/v1/screens/01GN9PW2Z03V8VQG7SN6Q9R17H');
15+
16+
$this->assertResponseRedirects('/v2/screens/01GN9PW2Z03V8VQG7SN6Q9R17H', 301);
17+
}
18+
}

0 commit comments

Comments
 (0)