The clean & modern RSS server that doesn't give you any crap.
https://thearsse.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.4 KiB
41 lines
1.4 KiB
7 years ago
|
<?php
|
||
7 years ago
|
/** @license MIT
|
||
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
||
|
* See LICENSE and AUTHORS files for details */
|
||
|
|
||
7 years ago
|
declare(strict_types=1);
|
||
5 years ago
|
namespace JKingWeb\Arsse\REST\NextcloudNews;
|
||
7 years ago
|
|
||
6 years ago
|
use Psr\Http\Message\ServerRequestInterface;
|
||
|
use Psr\Http\Message\ResponseInterface;
|
||
6 years ago
|
use Zend\Diactoros\Response\JsonResponse as Response;
|
||
|
use Zend\Diactoros\Response\EmptyResponse;
|
||
7 years ago
|
|
||
7 years ago
|
class Versions implements \JKingWeb\Arsse\REST\Handler {
|
||
7 years ago
|
public function __construct() {
|
||
7 years ago
|
}
|
||
7 years ago
|
|
||
6 years ago
|
public function dispatch(ServerRequestInterface $req): ResponseInterface {
|
||
|
if (!preg_match("<^/?$>", $req->getRequestTarget())) {
|
||
|
// if the request path is more than an empty string or a slash, the client is probably trying a version we don't support
|
||
6 years ago
|
return new EmptyResponse(404);
|
||
6 years ago
|
}
|
||
|
switch ($req->getMethod()) {
|
||
|
case "OPTIONS":
|
||
|
// if the request method is OPTIONS, respond accordingly
|
||
|
return new EmptyResponse(204, ['Allow' => "HEAD,GET"]);
|
||
|
case "GET":
|
||
|
// otherwise return the supported versions
|
||
|
$out = [
|
||
|
'apiLevels' => [
|
||
|
'v1-2',
|
||
|
]
|
||
|
];
|
||
|
return new Response($out);
|
||
|
default:
|
||
|
// if any other method was used, this is an error
|
||
|
return new EmptyResponse(405, ['Allow' => "HEAD,GET"]);
|
||
7 years ago
|
}
|
||
|
}
|
||
7 years ago
|
}
|