0

I am sure this will be a simple question but I want to make sure I use the correct terminology for a meeting explaining my new API.

So if I have the following URIs for my API:

So these are 3 controllers in the same Web API. In conversation is this considered 1 endpoint or 3 endpoints?

David
  • 73
  • 7
  • As a consumer of API's I'd argue its 4 endpoints :-) there are 4 endpoints I can hit that will do 4 different things – Blundell Jun 08 '21 at 20:59

2 Answers2

0

Well, the responsibility of each one are different, it doesn't matter that they are acting in the same resource, so, for practice, all of that are different endpoint, you could put the 1 and 2 in the same one, but the 3 need to be a different product.

sGermosen
  • 312
  • 3
  • 14
0

In conversation is this considered 1 endpoint or 3 endpoints?

The REST answer is "0 endpoints".

There is no such thing as a REST endpoint -- Fielding, 2018

What you show here are three resource identifiers, and by implication three resources.

The fact that those three resources each have a separate "controller" is an accident of your implementation. REST really doesn't care.

In a context like OpenAPI 3, you will also see this described as four "operations" (path + method).

(You'll also see that the OpenAPI 3 documentation seems to consider "resource" and "endpoints" to be equivalent.)

Given Hohpe's description of the MessageEndpoint pattern, I'm inclined to think that resource isn't a particularly good match for "endpoint".

You might be able to argue that there is a message-endpoint in your web server process, which is handing off messages to your controllers? In which case, that would be one endpoint.


Are you saying I should have combined up some of the verbs into less controllers?

No, I'm not saying that. REST says that we need a client-stateless-server protocol with uniformly understood self descriptive messages. The HTTP specifications define self descriptive request messages and self descriptive response messages.

But the magic black box that decides what response to send to a request is yours. The number of controllers you decide to use is an implementation detail that is hidden from clients behind the HTTP facade.

There's nothing in REST, or HTTP, that requires/forbids that the server implementation use MVC.

VoiceOfUnreason
  • 52,766
  • 5
  • 49
  • 91
  • So I did some reading myself and your answer seems closest to the answer. In my example https//testapi.org would have been the endpoint but what I showed where REST resources as you mentioned. Resources are a subset of an endpoint. https://stackoverflow.com/questions/30580562/what-is-the-difference-between-resource-and-endpoint – David Jun 09 '21 at 21:30
  • Also you said my having three controllers was an "accident" of my implementation. Are you saying I should have combined up some of the verbs into less controllers? Well I did that way to make sure it was clear organizationally separating the concerns. There is no doubt what type of actions are contained under "registration" and "token". – David Jun 09 '21 at 21:35