Plain text mode added.

This commit is contained in:
Alexey Skobkin 2018-11-02 18:50:08 +03:00
parent fceaca6d02
commit 97d87d9049
2 changed files with 5 additions and 0 deletions

View file

@ -33,6 +33,8 @@ final class AppKernel
// It's a kind of routing you know...
if ('/json' === $request->getPathInfo()) {
$format = DetectorController::FORMAT_JSON;
} elseif ('/plain' === $request->getPathInfo()) {
$format = DetectorController::FORMAT_PLAIN;
} elseif ('/' === $request->getPathInfo()) {
$format = DetectorController::FORMAT_HTML;
} else {

View file

@ -10,6 +10,7 @@ final class DetectorController
{
public const FORMAT_JSON = 'json';
public const FORMAT_HTML = 'html';
public const FORMAT_PLAIN = 'plaintext';
private const TEMPLATES_PATH = AppKernel::PROJECT_ROOT.'/templates';
@ -23,6 +24,8 @@ final class DetectorController
if (static::FORMAT_JSON === $format) {
return new JsonResponse($clientData);
} elseif (static::FORMAT_PLAIN === $format) {
return new Response($request->getClientIp());
}
$templater = new PhpRenderer(static::TEMPLATES_PATH);