0

There's plenty of resources that outline how URLs should be organized for RESTful APIs but for web in general there's little to be found.

How can I structure the URLs of the web pages so that they are

  1. Sensible from the perspective of a user browsing the web
  2. Sensible from a separation of concerns in a Spring framework controller

To apply some context let's assume there's groups that contains elements and there are uses cases to create, view, edit and delete both.

Johan Sjöberg
  • 47,929
  • 21
  • 130
  • 148

2 Answers2

0

You may have had trouble finding information about this since it's a question that touches on Information Architecture (IA) and SEO, in addition to application design. If your application or site is available on the internet (rather than an internal private network) then you have to optimize multiple, sometimes conflicting, constraints:

  1. Making the urls sensible and understandable to users
  2. Make your scheme manageable and scalable
  3. Understand which portions of your app or site need to be indexible by search engines
  4. Maintain good application design (think SOLID)
  5. Probably several others ...

In general, I would suggest that you start with identifying your constraints, and consider "what makes sense to users" as a high priority one. Then try to work in other constraints from there. Since you mention separation of concerns, you have a good sense of what some of your design constraints are. Ultimately, it's up to you (and maybe your business SMEs) to determine which constraints need to be rigid, and which others can be relaxed.

Michael Peacock
  • 2,011
  • 1
  • 11
  • 14
0

After consideration I've come to think this

/groups/create
/group/{gid}/
/group/{gid}/edit
/group/{gid}/delete
/group/{gid}/elements/create
/group/{gid}/element/{eid}/
/group/{gid}/element/{eid}/edit
/group/{gid}/element/{eid}/delete

The only drawback is that groups are created against /groups/create rather than /group/create because otherwise the group name create would become illegal.

Another variant is to attach the id at the very end, but urls quickly become clumsy

/groups/create
/groups/view/{id}
/groups/edit/{id}
/groups/delete/{id}
/groups/view/{id}/element/create
/groups/view/{id}/element/view/{eid}
/groups/view/{id}/element/edit/{eid}
/groups/view/{id}/element/delete/{eid}
Johan Sjöberg
  • 47,929
  • 21
  • 130
  • 148