API Custom Endpoints

I couldn’t find a way to connect Controller to route in a custom endpoint in API V8.

Here’s my code:

/custom/application/Ext/Api/V8/Config/routes.php

<?php


$app->get('/rub/{name}', function ($request, $response, $args){

$arg = $args['name'];

$data = array('message' => $arg);

return $response->withJson($data);

});

that’s ok. But when i add a Controller, the response is empty with a 500 error code.

<?php

$app->get('/rub/{name}', 'CustomController:CustomAction'); 

?>

/custom/application/Ext/Api/V8/controllers.php

<?php

class CustomController extends BaseController{

public function CustomAction($request, $response){

$arg = $args['name'];

$data = array('message' => $arg);

return $response->withJson($data);
}
}

?>

Any idea?

thanks.