diff --git a/api/routes/category.php b/api/routes/category.php index 6a344a0..cb5856e 100644 --- a/api/routes/category.php +++ b/api/routes/category.php @@ -20,6 +20,32 @@ "name" => $cat->getName() ]; } + $response = $response->withJSON($response_json); + return $response; +}); + +/** +* GET Category by ID +* @param id int PK of known category +*/ + +$app->get('/category/{id}', function( $request, $response ) { + $q = new CategoryQuery; + $cat = $q->findPK($request->getAttribute('id')); + + $response_json = [ + "status" => [ + "code" => $response->getStatusCode(), + "message" => "OK" + ], + "data" => [] + ]; + + $response_json["data"][] = [ + "id" => $cat->getId(), + "name" => $cat->getName() + ]; + $response = $response->withJSON($response_json); return $response; }); \ No newline at end of file