mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Implemented redirection for SPA
This commit is contained in:
parent
022cac0dc1
commit
77cd11233d
@ -3,7 +3,9 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* Offers an SPA with Vue.js.
|
||||
@ -12,12 +14,32 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
* @see https://de.wikipedia.org/wiki/Single-Page-Webanwendung
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Write tests!
|
||||
*/
|
||||
class SPAController extends AbstractController
|
||||
final class SPAController extends AbstractController
|
||||
{
|
||||
public function spa(Request $request): Response
|
||||
/**
|
||||
* @todo put this in an .env file
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const SPA_PORT = 82;
|
||||
|
||||
private function getSpaUrl(Request $request): string
|
||||
{
|
||||
$url = str_replace('/spa/', '', $request->getUri());
|
||||
$url = str_replace('/spa', '', $url);
|
||||
$url .= ':'.self::SPA_PORT;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/spa",methods={"GET"})
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function spa(Request $request): RedirectResponse
|
||||
{
|
||||
return new RedirectResponse($this->getSpaUrl($request));
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class RoutesGetStatusIntegrationTest extends KernelTestCase
|
||||
'register' => 301,
|
||||
'logout' => 302,
|
||||
'profile/edit' => 302,
|
||||
'spa' => 200,
|
||||
'spa' => 302,
|
||||
];
|
||||
|
||||
public function setUp(): void
|
||||
|
Loading…
Reference in New Issue
Block a user