Home  >  Article  >  Backend Development  >  How to name the login interface in RESTful?

How to name the login interface in RESTful?

WBOY
WBOYOriginal
2016-08-04 09:20:152103browse

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?

Reply content:

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...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn