Routing vs Mapping terminology for Spring REST API

917 Views Asked by At

My question is simple. When defining the URL paths for Spring REST API resources, do you call them routes, or mappings? So for example would https://www.myapp.com/api/person/123 be called a route to a person resource, or a mapping to a person resource? I have seen both terms used when researching this, and they seem to be somewhat interchangeable but I would like an actual answer. I have tried searching for this but can't seem to find anything on the topic.

1

There are 1 best solutions below

0
On BEST ANSWER

The Spring docs and the Spring codebase consistently use the term: mapping.

For example:

  • @RequestMapping
  • "Annotation for mapping web requests onto specific handler classes and/or handler methods..." (my emphasis)
  • "The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings..." (my emphasis)
  • ... etc

By contrast, the Spring MVC docs make no mention of "routing" or "routes".

However, in general usage the term "routing" is (in my experience, at least) ~common ...

  • It adequately describes what's being done i.e. requests are being routed by some sort of dispatcher to a specific controller
  • Other frameworks (e.g. the Play Framework) use the terms "routing" and "routes"

So, I suspect people will understand your meaning if you use that term however if you want to avoid ambiguity then the more correct form, in the context of a Spring REST API, is "mapping".