T
T
Tsiren Naimanov2016-03-26 10:50:58
ASP.NET
Tsiren Naimanov, 2016-03-26 10:50:58

How to place REST methods in a controller?

I have only 22 objects, for each you need to write a get view, and the post rest methods (adding, updating, deleting, viewing)
I have 3 main controllers created according to the meaning, so let
's say each has 5-10 entities.
What is better, to continue doing this, or to create a controller with a view and post methods for each entity ???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2016-03-26
@ImmortalCAT

Controllers are your projections of the entities in the service (roughly speaking, the objects of your business logic classes) to the web API resources provided by the service. Which entities to project onto resources and which not depends entirely on what kind of API you want to get in the end. In which controllers to do this and whether it is worth splitting N controllers into M controllers - depends on how it is convenient for you to implement them. Well, this is about the same as asking "is it worth breaking 5 classes into 10?". Each controller has its own responsibility. If you clearly understand the responsibility of each controller, you don't need to break it. If you stopped understanding and some controller started doing too many different things, you need to break it.
You need to understand that it is better to first design the interaction interfaces of large components: clients and services, and then implement these interfaces. In the case of REST, you first design the REST API based on the needs of your application, and then implement the service and client.
I didn't understand this sentence.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question