C
C#2y ago
big OOF

❔ QuestionController

Hello, i have a question regarding API structure. I have two classses, Item and Store. I created CRUD endpoints for both. Lets say i want to be able to return a store including all the items related to that store, and also be able to to POST a store with items. Would you create a seperate controller for these endpoints, for example StoreIemController containing PostStoreWithItems/GetAllStoresWithItems or use existing Store/ItemController? Thanks in advance 🙂
5 Replies
Dusty
Dusty2y ago
Wouldn't that be a good fit for nesting? Like GET /Store/{storeId}/Items Same for post
big OOF
big OOFOP2y ago
Souns like a good idea! I have a endpoint for bith Store and item, lets say i have a webpage that allows the user to add a new store and the stores items. Would you use two seperate calls(POST store and POST Item) or would you create anew POST-endpint? In that case it would be only one endpoint instead of two but i would have to seperate the POST-body to be able to insert it to the Store and Item table in the DB 🙂
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Dusty
Dusty2y ago
Hmm it depends on how you structured your UI In general I'd stick to the REST pattern
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server