aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/homepage.php
blob: c99dce46bdf566d873343e3db790742222d239f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

use Digitigrade\HttpResponseStatus\NotFound;
use Digitigrade\HttpResponseStatus\TemporaryRedirect;
use Digitigrade\Model\UserAccount;
use Digitigrade\Router;

Router::getInstance()->mount('/', function (array $args) {
    $accept = $_SERVER['HTTP_ACCEPT'] ?? '';
    if (str_contains($accept, 'text/html') || str_contains($accept, '*/*')) {
        throw new TemporaryRedirect(
            UserAccount::findByCurrentSession() == null
            ? '/feed/global'
            : '/feed/home'
        );
    }
    throw new NotFound();
});