asp.net - Routing of Api Controllers Design -
i'm creating dotnet core web api , have defined api spec. have users can have assignments linked eachother.
for creating user i'm using route:
post /users { "name": "user name" }
this done within userscontroller
for creating assignment , hook user thought of url: /users/{userid}/assignments
, adding get/post/patch/delete
method.
my question: 1 split in multiple controllers (userscontroller , assignmentcontroller) or 1 controller (userscontroller) , generate routes there?
it personal preference, , depends on how big userscontroller
is.
if have many codes in userscontroller
, might consider creating assignmentcontroller
. following single responsibility principle.
on other hand, if inside userscontroller
related user, i'll keep there. you can @ this controller sample.
Comments
Post a Comment