I'm building a REST API. I don't want to have real folders in my directory structure, but I'm not quite sure what to use else. My REST API uses paths like this:
<object> is the object the action
<action> should be performed on. For example, a URL
api.server.com/user/create would create a new user.
For now, I've come up with this:
- The objects all have their own file, like
user.phpfor the object
/user/. In the GET variable
actiona string determining the action is stored.
I'm using a .htaccess rewrite script to rewrite the fake directories to these internal paths:
RewriteEngine On RewriteRule ^(.*?)/(.*?)/?$ $1.php?action=$2 [NC,L]
However, I'm not sure if this is the best way of setting up a REST API. Would there be any obvious problems I'm missing here?
How does the internal file tree of a REST API usually look, or can't that be reasonably said? What are the pros and cons of different approaches?