当前位置:网站首页>Tslint annotations ignore errors and restful understanding
Tslint annotations ignore errors and restful understanding
2022-04-23 05:21:00 【process1212】
restful It is recommended to see the great God's blog
tslint Comment mark
ts Use the following comment in the file to temporarily ignore the error of the rule , Reference here
- / tslint:disable /—— Ignore the error prompt in all the following code on this line
- / tslint:enable /—— At present ts File re enable tslint
- // tslint:disable-line—— Ignore the error prompt in the current line of code
- // tslint:disable-next-line—— Ignore the error prompt in the next line of code
RESTful
A style of software architecture 、 Design style , and No standard , It just provides a set of design principles and constraints . It is mainly used for the software of interaction between client and server . Software designed based on this style can be more concise , More layers , It is easier to implement caching and other mechanisms .
Principle conditions :
Web The most important part of an application is REST The principle is , The interaction between client and server is stateless between requests . Every request from the client to the server must contain the information necessary to understand the request . If the server restarts at any point in time between requests , The client will not be notified . Besides , Stateless requests can be answered by any available server , This is very suitable for Cloud computing Or something like that . Clients can cache data to improve performance .
On the server side , Application state and function can be divided into various resources . Resources are an interesting conceptual entity , It's open to clients . Examples of resources are : Application object 、 Database records 、 Algorithm, etc. . Every resource uses URI (Universal Resource Identifier) Get a unique address . All resources share a unified interface , To transfer state between client and server . It's standard HTTP Method , such as GET、PUT、POST and DELETE.Hypermedia Is the status of the application engine , Resources are represented by Hyperlinks interconnection .
PRC: Remote procedure call
RFC:request for comments Request comments
The purpose of my article , I want to be consistent with the principle of architecture , Understand and evaluate the architecture design of web-based applications , Get a powerful 、 Good performance 、 Architecture suitable for communication .REST A set of architectural constraints and principles .
REST It doesn't create new technology in itself 、 Components or services , And hidden in RESTful The idea behind it is to use Web The existing characteristics and capabilities of , Better use of existing Web Some criteria and constraints in the standard . although REST Self acceptance Web Technology has a profound impact , But in theory REST The architectural style is not tied to HTTP On , Just for now HTTP Is the only one with REST Relevant examples . So what we're describing here REST through HTTP Realized REST.
From the definition of resources 、 obtain 、 describe 、 relation 、 State change and so on , List and explain some key concepts :
Resources and URI
** Anything , As long as there is a need to be quoted , It's a resource . Resources can be entities ( For example, cell phone numbers ), It can also be just an abstract concept ( For example, value ) **
URI:uniform resource identifier
URI The design of the system should follow the principle of addressability , Self descriptive , Need to give people an intuitive connection in form .
Unified resource interface
RESTFul Architecture should follow the principle of unified interface , The unified interface contains a limited set of predefined operations , No matter what kind of resources , All access resources through the same interface .
GET
- Safe and idempotent
- Get representation
- Get representation on change ( cache )
- 200(OK) - Indicates that... Has been issued in the response
- 204( There is no content ) - If the resource is empty, it means
- 301(Moved Permanently) - Resources URI Has been updated
- 303(See Other) - other ( Such as , Load balancing )
- 304(not modified)- The resource has not changed ( cache )
- 400 (bad request)- A bad request ( Such as , Parameter error )
- 404 (not found)- Resource does not exist
- 406 (not acceptable)- The server does not support the required representation
- 500 (internal server error)- General error response
- 503 (Service Unavailable)- The server is currently unable to process the request
POST
- Not safe and idempotent
- Using server managed ( Automatically generate ) Instance number of create resource
- Create sub resources
- Partial update resources
- If it's not modified , But update the resources ( Optimism lock )
- 200(OK)- If an existing resource has been changed
- 201(created)- If a new resource is created
- 202(accepted)- Processing request accepted but not completed ( Asynchronous processing )
- 301(Moved Permanently)- Resources URI Be updated
- 303(See Other)- other ( Such as , Load balancing )
- 400(bad request)- A bad request
- 404 (not found)- Resource does not exist
- 406 (not acceptable)- The server does not support the required representation
- 409 (conflict)- Generic conflict
- 412 (Precondition Failed)- Precondition failed ( Such as the conflict when executing condition update )
- 415 (unsupported media type)- The received expression is not supported
- 500 (internal server error)- General error response
- 503 (Service Unavailable)- The service is currently unable to process the request
PUT
- Unsafe but idempotent
- Create a resource with the instance number managed by the client
- Update resources by replacing
- If not modified , Update resources ( Optimism lock )
- 200 (OK)- If an existing resource is changed
- 201 (created)- If a new resource is created
- 301(Moved Permanently)- Resources URI Has been changed
- 303 (See Other)- other ( Such as , Load balancing )
- 400 (bad request)- A bad request
- 404 (not found)- Resource does not exist
- 406 (not acceptable)- The server does not support the required representation
- 409 (conflict)- Generic conflict
- 412 (Precondition Failed)- Precondition failed ( Such as the conflict when executing condition update )
- 415 (unsupported media type)- The received expression is not supported
- 500 (internal server error)- General error response
- 503 (Service Unavailable)- The service is currently unable to process the request
DELETE
- Unsafe but idempotent
- Delete resources
- 200 (OK)- The resource has been deleted
- 301 (Moved Permanently)- Resources URI Has been changed
- 303 (See Other)- other , Such as load balancing
- 400 (bad request)- A bad request
- 404 (not found)- Resource does not exist
- 409 (conflict)- Generic conflict
- 500 (internal server error)- General error response
- 503 (Service Unavailable)- The server is currently unable to process the request
“ client / Form of server ”, Built on a distributed system , Communicate over the Internet , With high delay (high latency)、 High concurrency .
How to develop software used in Internet Environment .
RESTful framework , Is the most popular Internet software architecture . Represent layer state transformation
It has a clear structure 、 Meet the standard 、 Easy to understand 、 Easy to expand , So more and more websites are using .
R resources :
REST The name of " Represent layer state transformation " in , Omit the subject .“ The presentation layer " In fact, it means " resources ”(Resources) Of " The presentation layer ".
** So-called " resources ", It's an entity on the Internet , Or a specific information on the Internet .** It can be a piece of text 、 A picture 、 A song 、 A service , In a word, it is a concrete reality . You can use one URI( Uniform resource locator ) Pointing to it , Each resource corresponds to a specific URI. To get this resource , Visit its URI Can , therefore URI It becomes the address or unique identifier of each resource .
R The presentation layer representation:
" resources " It's an information entity , It can have many external forms . We put " resources " In the form of , It's called it " The presentation layer "(Representation)
URI Entities that represent resources only , Does not represent its form . Strictly speaking , Some of the last ".html" Suffixes are unnecessary , Because this suffix means format , Belong to " The presentation layer " Category , and URI It should only represent " resources " The location of . Its concrete manifestation , belong HTTP The requested header information uses Accept and Content-Type Field assignment , These two fields are right " The presentation layer " Description of .
State transformation State Transfer:
Internet communication protocol HTTP agreement , It's a stateless protocol . It means , All States are saved on the server side . therefore , If the client wants to operate on the server , By some means , Let it happen on the server side " State transformation "(State Transfer). And this transformation is based on the presentation layer , So is " Represent layer state transformation ".
The means used by the client , Can only be HTTP agreement . say concretely , Namely HTTP In the agreement , Four verbs for operation :GET、POST、PUT、DELETE. They correspond to four basic operations :GET Used to obtain resources ,POST Used to create a new resource ( Can also be used to update resources ),PUT Used to update resources ,DELETE Used to delete resources .
Summarize what is RESTful framework :
(1) every last URI Represents a resource ;
(2) Between client and server , A layer of expression that conveys this resource ;
(3) Client through four HTTP Verb , Operate on the server-side resources , Realization " Represent layer state transformation ".
版权声明
本文为[process1212]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230519446035.html
边栏推荐
- Devops life cycle, all you want to know is here!
- mariadb数据库的主从复制
- Three 之 three.js (webgl)模型的删除/场景的清空/内存的释放 的简单整理
- Detailed explanation of concurrent topics
- Five key technologies to improve the devsecops framework
- Study notes: unity customsrp-10-point and spot shadows
- FileReader API file operation
- The annual transaction volume of the app store is US $1 million, and only 15% commission is paid. Small and medium-sized developers are very contradictory
- !!!!!!!!!!!!!!!!!!
- Basic use of sqlyog
猜你喜欢
Three 之 three.js (webgl)简单实现根据点绘制线/弧线(基于LineGeometry / Line2 / LineMaterial,绘制两点基于圆心的弧线段)
Domain driven model DDD (III) -- using saga to manage transactions
使用zerotier让异地设备组局域网
Publish your own wheel - pypi packaging upload practice
MySQL external connection, internal connection, self connection, natural connection, cross connection
如何在Word中添加漂亮的代码块 | 很全的方法整理和比较
Good simple recursive problem, string recursive training
Five key technologies to improve the devsecops framework
Qingdao agile tour, coming!
Cloud computing and cloud native architecture design of openshift
随机推荐
使用 Kears 实现ResNet-34 CNN
mariadb数据库的主从复制
看板快速启动指南
Three 之 three.js (webgl)模型的删除/场景的清空/内存的释放 的简单整理
Source code analysis of how to use jump table in redis
Laravel database
2021-11-08
JS Array常见方法
Study notes: unity customsrp-13-colorgrading
Unique primary key ID of tidb sub table -- solution to failure of sequence and Gorm to obtain primary key
Uniapp hot update with progress bar
【openh264】cmake: msopenh264-static
How to add beautiful code blocks in word | a very complete method to sort out and compare
WTL 自绘控件库 (CQsCheckComboxBox)
When is it appropriate for automated testing? (bottom)
Detailed explanation of concurrent topics
My old programmer's perception of the dangers and opportunities of the times?
改进DevSecOps框架的 5 大关键技术
DevOps生命周期,你想知道的全都在这里了!
node中的redis使用--ioredis