Answer the question
In order to leave comments, you need to log in
What is the best way to make controllers from the point of view of REST?
I have entities Student (student) and Tutor (teacher) .
There are two controllers respectively: StudentController and TutorController .
There is a task. We need to make an endpoint that will return students associated with a particular teacher. The endpoint should look like this: /tutors/{id}/students
, because in this case the teacher is the main resource.
In which of the controllers would it be more logical to place this endpoint?
Pros when hosted in a StudentController:
/students
)Answer the question
In order to leave comments, you need to log in
The method returns students, which means that it should be placed in the students controller. Tomorrow you will need to receive students by class number, by academic performance, etc., but you will not make separate controllers for this.
You may need to split the service into two, then your teacher service will get an extra connection with the student service.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question