Representational State Transfer REST architectural constraints

Опубликовано: 22 Май 2024
на канале: CodeWis Technologies by Nuhman Paramban
53
1

REST API Architectural Constraints

Overview

What is REST
Representational State Transfer
Architecture style
Set of rules for creating web services.
Using HTTP Protocol for communication
Uniform Predefined rule
Server - Own Resource
Client - Request Resource

Architectural Constraints
Uniform Interface
Stateless
Cacheable
Client-Server
Layered System
Code on Demand (Optional)


Uniform Interface
Rest is a client server model and client should have the ability to interact with server in a consistent and predictable way.
Resource based - Eg - Users, Books (URL should be based on that)
Standardized methods - GET, POST, PUT, DELETE
Stateless
Self Describing Response - Details about content
HATEOAS - further actions url

Stateless
No Server Side Memory
Self Contained Requests
Benefits of Statelessness
Scalability
Simplicity
Reliability
Flexibility

How to overcome Stateless
Authentication Token
Cookies (No ideal)

Self Describing Messages
Client understand server response without prior knowledge about the service
Clarity Without Confusion
Content Type (JSON/XML), Status Code(200, 201), Headers (Additional info), Payload(Optional)
Reduced Coupling, Interoperability, Easier maintenance
Additional - Media Type, Documentation (Swagger)

HATEOAS (Hypermedia as the Engine of Application State)
Client Driven Navigation, Reduced Coupling, Flexibility
How - Hypermedia Links, Content Type, Status Code
Benefits - Reduced Complexity, Improved maintainability, Discoverability
Drawbacks - Initial learning curve, complex response

Cacheable
Client Side Caching - Client application can cache
Server Side Caching - in memory cache and dedicated cache
Cache Invalidation - cache expiration
Cacheability in REST Responses (Server can control client caching)
Cache Control - no-cache or no-store to prevent caching entirely.
Expires
Benefits
Improved Performance
Reduced Server load
Increase Scalability
Enhanced User Experience


Designing Cacheable REST API
Identify Resources that are frequently access and relatively static
Set appropriate cache expiration time
Mechanism to invalidate cache if resource updated

Client-Server
Separation of Concerns b/w Client and Server
Independent Evolution
Well Defined interface (Resources/Standard methods)
Statelessness

Benefits of Client-Server Constraints
Scalability
Simplicity
Interoperability

Layered System
REST api communication can be broken down into distinct layers
Architecture divided into distinct layers, each with different functionality
Intermediate services b/w client and server
Caching
Security
Load balancing
Transparency - Client not need to aware


Code On Demand (Optional)
Server provide a code that client can execute
Encryption
Custom Rendering


Смотрите видео Representational State Transfer REST architectural constraints онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал CodeWis Technologies by Nuhman Paramban 22 Май 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 53 раз и оно понравилось 1 посетителям.