Home > Article > Backend Development > How to name the login interface in RESTful?
In the RESTful architecture, each URL represents a resource, so the URL cannot have verbs, only nouns, and the nouns used often correspond to the table names of the database. Generally speaking, the tables in the database are "collections" of the same type of records, so the nouns in the API should also be pluralized.
GET /zoos: List all zoos
POST /zoos: Create a new zoo
GET /zoos/ID: Get information about a specified zoo
PUT /zoos/ID: Update information about a specified zoo (provide the zoo’s All information)
PATCH /zoos/ID: Update the information of a specified zoo (provide partial information of the zoo)
DELETE /zoos/ID: Delete a certain zoo
The question is, how to name the login interface?
In the RESTful architecture, each URL represents a resource, so the URL cannot have verbs, only nouns, and the nouns used often correspond to the table names of the database. Generally speaking, the tables in the database are "collections" of the same type of records, so the nouns in the API should also be pluralized.
GET /zoos: List all zoos
POST /zoos: Create a new zoo
GET /zoos/ID: Get information about a specified zoo
PUT /zoos/ID: Update information about a specified zoo (provide the zoo’s All information)
PATCH /zoos/ID: Update the information of a specified zoo (provide partial information of the zoo)
DELETE /zoos/ID: Delete a certain zoo
The question is, how to name the login interface?
<code>POST /logins/</code>
<code>get sessions/new 登录页面 post sessions/create 登录 post sessions/destroy 注销 </code>
Abstract session into a resource
RESTful is just a naming suggestion, not a specification, so there is no problem if you use login/signup, and the boss will not deduct your salary for this.
If it must be so exquisite, I suggest you change your mind
Log in to get authorization
Get authorization. That makes it clear
Although I sometimes want to be sophisticated...but where it should be rough and innocuous, it's better to be simple and rough...because the work is done collaboratively...if the whole thing is too high-end and makes people look confused, I won't do it. So suitable...