📜 ⬆️ ⬇️

The most massive fallacy around the REST architecture

Faced with one major resource for developers with the wrong implementation of the REST architecture, I, following Intel, debunking the myths about Moore's law , want to draw attention to the most common mistake when implementing RESTful applications that violate the integrity of the network. At what practically all developers, web frameworks and even very popular resources (for example GitHub) sin, but ...


I'll start with a little background. Developing for the site authorization through Oauth, to the next request, I received the answer “404 Not found”. It's okay, I thought, I checked the documentation, looked into the code and was surprised - there should be no 404th error. As you may have guessed, then I checked every line of documentation and my program and spent some time searching for errors. When I discovered it, I was angry with myself and the github developers. What was the matter?

The problem was that the HTTP method that was specified in the request did not match in the code and the documentation. Wait a minute After all, the URL is an identifier (more precisely, its subtype), which means that under no circumstances should I have received the 404th error (it was this confidence that let me down). As a last resort, I expected to receive the 400th “Bad Request” header, but certainly not 404!
')
What was really going to happen? The standard for this case is HTTP status 405 “Method Not Allowed”, in this case the server is obliged to send a list of valid methods with the response. The standard does not specify in what form this list should be sent, but, obviously, in the form in which the client will be able to read it taking into account the “Accept” header.

As you may have guessed today, it is difficult to find a web framework or resource that would not repeat this mistake, more typical of beginners than harsh professionals. In my opinion, personal opinion, especially brightly and, perhaps, even comically, it looks against the background of the struggle for standardization of HTML with the ridicule of Microsoft that was launched at the time of popularization of REST architecture - HTTP was already standardized by that moment. The result of this is the possible loss of the backward compatibility of network nodes, and today the impossibility of the rapid integration of modern products into software systems in view of the need to customize each such application.

Source: https://habr.com/ru/post/237865/


All Articles