2017-03-19 02:30:36 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2017-03-28 04:12:12 +00:00
|
|
|
namespace JKingWeb\Arsse\REST\NextCloudNews;
|
|
|
|
use JKingWeb\Arsse\REST\Response;
|
2017-03-19 02:30:36 +00:00
|
|
|
|
2017-03-28 04:12:12 +00:00
|
|
|
class Versions extends \JKingWeb\Arsse\REST\AbstractHandler {
|
2017-03-28 22:50:00 +00:00
|
|
|
function __construct() {
|
2017-03-19 02:30:36 +00:00
|
|
|
}
|
|
|
|
|
2017-03-28 04:12:12 +00:00
|
|
|
function dispatch(\JKingWeb\Arsse\REST\Request $req): \JKingWeb\Arsse\REST\Response {
|
2017-03-24 17:16:34 +00:00
|
|
|
// if a method other than GET was used, this is an error
|
2017-03-20 01:50:00 +00:00
|
|
|
if($req->method != "GET") {
|
|
|
|
return new Response(405);
|
|
|
|
}
|
2017-04-02 03:06:52 +00:00
|
|
|
if(preg_match("<^/?$>",$req->path)) {
|
2017-03-24 17:16:34 +00:00
|
|
|
// if the request path is an empty string or just a slash, return the supported versions
|
2017-03-20 01:54:28 +00:00
|
|
|
$out = [
|
|
|
|
'apiLevels' => [
|
2017-03-24 17:16:34 +00:00
|
|
|
'v1-2',
|
2017-03-20 01:54:28 +00:00
|
|
|
]
|
|
|
|
];
|
|
|
|
return new Response(200, $out);
|
2017-03-20 01:50:00 +00:00
|
|
|
} else {
|
2017-03-24 17:16:34 +00:00
|
|
|
// if the URL path was anything else, the client is probably trying a version we don't support
|
2017-03-20 01:50:00 +00:00
|
|
|
return new Response(404);
|
|
|
|
}
|
2017-03-19 02:30:36 +00:00
|
|
|
}
|
|
|
|
}
|