vendredi 7 avril 2017

Routing of Api Controllers Design

I'm creating a dotnet core web api and have defined my api spec. For now i have users which can have assignments linked to eachother.

For creating an user i'm using this route:

POST /users
{
  "name": "User name"
}

This is all done within a Userscontroller

For creating an assignment and hook it up to an user i thought of this url: /users/{userId}/assignments and adding a GET/POST/PATCH/DELETE method.

My question: would one split it in multiple controllers (userscontroller and assignmentcontroller) or one controller (userscontroller) and generate routes from there?

Aucun commentaire:

Enregistrer un commentaire