1

Let's say we want a RESTful web service to manage some logically nested resources, where each instance of resource 'B' is logically contained by an instance of resource 'A'. The first example that comes to mind, working as a sysadmin, is email accounts and their domains: [email protected] [email protected] [email protected] ...

What URL scheme would you suggest? At first I'd try:

 /domain/[domainname]
 /domain/[domainname]/account/[accountname]

is that in line with RESTful principles? or should I go with something like:

 /domain/[domainname]
 /account/[account@domainname]/

or anything else?

1 Answer 1

3

The question is one of "Navigation" and "Independence".

Does an account have meaning outside a specific domain? Generally it doesn't. So the account doesn't really have a separate top-level path.

However, using /domain/[domainname]/account/[accountname] with a label in the middle of the URI doesn't look very nice, either. The words 'domain' and 'account' aren't very useful.

You're happier with something like this:

/domain/[domainname]/  -- general information about the domain
/account/[domainname]/[account]/ -- a specific account within the domain.

The top of the path is the classifier for the kind of data.

The rest of the path is the way to navigate to that piece of data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.