Question

I really like Restler on first blush but I wanted to make sure I could implement my requirements and my first attempt fell short but that's likely due to me not understanding it fully.

What I'd like to be able to do is have a set of families of services such as:

  • users
  • app
  • actions
  • relationships

and then be able to have a rest service such as:

Ideally I'd like to have the class definitions be segmented at the sub-type level. So in the example above I'd have a "preferences" and "goals" class that handles requests under the "user" part of the service architecture.

I've tried auto and manual routing (using @url operator) but I can't seem to get it to work.

Was it helpful?

Solution

Restler 2 and Restler 3 uses the class name as the path segment when path segment is not specified when we add API Class

Restler::addAPIClass($classname, $path=null); 

Map preferences and goals as follows

$r->addAPIClass('Preferences', 'user/preferences');
$r->addAPIClass('Goals', 'user/goals');

If you want to handle everything from manual routing alone (no path segment from class)

$r->addAPIClass('Preferences', '');
$r->addAPIClass('Goals', '');

and then use @url comments

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top