Register your route in web/index.php
$router->map('GET','/recipes','\Green\Http\Controllers\RecipeController::index');
RecipeController
class RecipeController extends MainController
{
use PsrToHttpFoundation,HttpFoundationToPsr;
public function __construct()
{
$this->recipeService = new RecipeService;
}
public function index(ServerRequestInterface $request, ResponseInterface $response)
{
$request = $this->toSymfonyRequest($request);
$recipes = $this->recipeService->all($request->query);
$response = new JsonResponse($recipes);
return $this->toPsrResponse($response);
}
See more under Green\Http\Controllers and Green\Services
It is configured to response json error response.
The default will show error detail for debugging purpose.
You can disable under web/config/app.php
<?php
return [
'debug' => false
];
It is supported by Jwt token. You can access current user using like below. If the user is not authenticated, it will response token error.
$request->user();