1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-25 10:02:40 +00:00
Arsse/lib/REST/Miniflux/Status.php

37 lines
1.1 KiB
PHP
Raw Normal View History

2020-11-23 14:31:50 +00:00
<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace JKingWeb\Arsse\REST\Miniflux;
use JKingWeb\Arsse\Misc\HTTP;
2020-11-23 14:31:50 +00:00
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
class Status extends \JKingWeb\Arsse\REST\AbstractHandler {
public function __construct() {
}
public function dispatch(ServerRequestInterface $req): ResponseInterface {
$target = parse_url($req->getRequestTarget())['path'] ?? "";
if (!in_array($target, ["/version", "/healthcheck"])) {
return HTTP::respEmpty(404);
2020-11-23 14:31:50 +00:00
}
$method = $req->getMethod();
if ($method === "OPTIONS") {
return HTTP::respEmpty(204, ['Allow' => "HEAD, GET"]);
2020-11-23 14:31:50 +00:00
} elseif ($method !== "GET") {
return HTTP::respEmpty(405, ['Allow' => "HEAD, GET"]);
2020-11-23 14:31:50 +00:00
}
$out = "";
if ($target === "/version") {
$out = V1::VERSION;
} elseif ($target === "/healthcheck") {
$out = "OK";
}
2022-08-06 17:40:02 +00:00
return HTTP::respText($out);
2020-11-23 14:31:50 +00:00
}
}