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

use WpfTest\HttpResponseStatus\NotFound;
use WpfTest\Model\Note;
use WpfTest\Router;

Router::getInstance()->mount('/post/:id', function (array $args) {
    $note = Note::find($args['id']);
    if ($note == null) {
        throw new NotFound("i don't know that note");
    }
    if (!$note->author->isLocal) {
        throw new NotFound("i don't want to tell you about non local posts sorry");
    }
    json_response($note);
});