Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I'm currently design a new API and a webapp that uses the API.

For example, suppose I have the following REST resources: (using a spring-boot microservice):

GET    /orders            // get all orders
POST   /orders            // create an order 
GET    /orders/1          // get order with id 1
PUT    /orders/1          // update order with id 1

GET    /orders/1/items    // get all order items
POST   /orders/1/items    // create an order item
GET    /orders/1/items/2  // get the order item with id 2 of order with id 1
PUT    /orders/1/items/2  // update order item with id 2 of order with id 1

I think, this is a very common usage. In my application, resources are much more nested.

I'm using angular with the ui-router and I want to define states/URLs for the according forms/views that are as closly as possible to the REST-API. Since it's not possible to use the same URL for GET, POST, PUT, I want to know what are standard (best practices) for defining those states.

Almost all text, tutorials etc. uses the following URLs/states for the CRUD methods:

/#/orders/              // state: orders
/#/orders/create        // state: orders.create
/#/orders/1/show        // state: orders.show
/#/orders/1/edit        // state: orders.edit

This is fairly straight forward. But no one discusses how to design nested resources. Thus, it would be interesting how you would handle the nested item resource?

Normally, I want to have a nested view with a controller to show the items, so that the items is a child-state of the orders.show state.

Therefore, If i would use the same scheme as suggested in the books/tutorials, it would result into the following urls:

/#/orders/1/show/items          // state: orders.show.items
/#/orders/1/show/items/create   // state: orders.show.items.create
/#/orders/1/show/items/2/show   // state: orders.show.items.show
/#/orders/1/show/items/2/edit   // state: orders.show.items.edit

But: These URLs somehow do not look correct. So, what experiences and recommendations exists? Or what are some suggestions to get a clean URL and therefore a clean application structure?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.