SlideShare a Scribd company logo
THE GLORY OF REST
THEORY
Source: www.redorbit.com
WEB SERVICE
A web service is an abstraction layer, like an
operating system API or a programming
language library.
RPC-STYLE ARCHITECTURES
envelope full of data
HTTP and SOAP are envelope formats
RPC-Style service defines it's own vocabulary
RESTful WS share standard HTTP methods vocabulary
REST Uniform Interface
RESTful - different URIs for different values
RPC-style - URI (service endpoint) for something that can be
processed as a command
REST-RPC HYBRID ARCHITECTURES
Web service between the RESTful web
services and the purely RPC-style services
FEW REST-RPC EXAMPLES
The
The "REST"
Many other allegedly RESTful web services
Most web applications
del.icio.us API
Flickr web API
SOAP AS A COMPETITOR TO REST
The primary competitors to RESTful
architectures are RPC architectures, not
specific technologies like SOAP.
RICHARDSON MATURITY MODEL
Source: http://martinfowler.com
LEVEL 0 - THE SWAMP OF POX
HTTP POST for all interactions
LEVEL 1 - RESOURCES
Distinct URL per object
LEVEL 2 - HTTP VERBS
Rather than doing RPC style methods, we
leverage HTTP
LEVEL 3 - HYPERMEDIA CONTROLS
Self-describing API
SO WHAT IS THIS REST
THING?
REST simply dictates that a given resource have a unique
address.
You can interact with that address with standard HTTP verbs.
STATE AND
STATELESSNESS
TWO TYPES OF STATE:
1. application state - live on the client
2. resource state - live on the server
Resource state stays on the server and is only sent to the
client in the form of representations.
Application state stays on the client until it can be used to
create, modify, or delete a resource. Then it's sent to the
server as part of POST, PUT, or DELETE request, and
becomes resource state.
RESTful service is "stateless" if the server never stores any
application state.
This is where the name "Representational State Transfer"
comes from.
ETAGS
ETags are used to compare entities from the
same resource. By supplying an entity tag
value in a conditional request header.
RESOURCE-ORIENTED
BASICS
different audience
everything (interesting) thing represent as a resource
representation of resources
verbs, auxiliaries, complexity
THE GENERIC ROA PROCEDURE
1. Figure out the data set
2. Split the data set into resources
For each kind of resource:
3. Name the resources with URIs
4. Expose a subset of the uniform interface
5. Design the representation(s) accepted from the client
6. Design the representation(s) served to the client
7. Integrate this resource into existing resources, using hypermedia links
and forms
8. Consider the typical course of events: what’s supposed to happen?
Standard control flows like the Atom Publishing Protocol can help.
9. Consider error conditions: what might go wrong? Again, standard control
flows can help.
ADDRESSABILITY
REPRESENTATIONS SHOULD BE ADDRESSABLE
CONNECTEDNESS
UNIFORM INTERFACE
GET, PUT, AND DELETE
POST
HEAD AND OPTIONS
Retrieve a metadata-only representation: HTTP HEAD
Check which HTTP methods a particular resource
supports: HTTP OPTIONS
PUT VERSUS POST
OVERLOADING POST
The real information may be in the URI, the
HTTP headers, or the entity-body. However it
happens, an element of the RPC style has
crept into the service.
SAFETY AND
IDEMPOTENCE
When correctly used, GET and HEAD
requests are safe. GET, HEAD, PUT and
DELETE requests are idempotent.
URI DESING
URIs are supposed to designate resources, not
operations on the resources.
MethodMethod URI TemplateURI Template Equivalent RPCEquivalent RPC
OperationOperation
PUT users/{username} createUserAccount
GET users/{username} getUserAccount
PUT users/{username} updateUserAccount
DELETE users/{username} deleteUserAccount
GET users/{username}/profile getUserProfile
POST users/{username}/bookmarks createBookmark
PUT users/{username}/bookmarks/{id} updateBookmark
DELETE users/{username}/bookmarks/{id} deleteBookmark
GET users/{username}/bookmarks/{id} getBookmark
GET users/{username}/bookmarks?tag=
{tag}
getUserBookmarks
GET {username}?tag={tag} getUserPublicBookmarks
GET ?tag={tag} getPublicBookmarks
Use commas when the order of the items matters, as it
does in latitude and longitude: /earth/37.0,-95.2
Use semicolons when the order doesn’t matter: /color-
blends/red;blue
When designing URIs, use path variables to separate
elements of a hierarchy, or a path through a directed graph.
Use query variables only to suggest arguments being
plugged into an algorithm, or when the other two
techniques fail.
REPRESENTATIONS
Representations should be human-readable,
but computer-oriented
SERVICE VERSIONING
Even a well-connected service might need to
be versioned
SECURITY
HMAC
"Authorization: AWS " + AWSAccessKeyId+ ":" +
base64(hmac-sha1(VERB + "n" +
CONTENT-MD5 + "n" +
CONTENT-TYPE + "n" +
DATE + "n" +
CanonicalizedAmzHeaders + "n" +
CanonicalizedResource))
Authorization: AWS 44CF9590006BF252F707:jZNOcbfWmD/A/f3hSvVzXZjM2HU=
JSON OR XML
JSON
If all you want to pass around are atomic
values or lists or hashes of atomic values,
JSON has many of the advantages of XML: it’s
straightforwardly usable over the Internet,
supports a wide variety of applications, it’s
easy to write programs to process JSON, it
has few optional features, it’s human-legible
and reasonably clear, its design is formal and
concise, JSON documents are easy to create,
and it uses Unicode.
If you’re writing JavaScript in a web browser,
JSON is a natural fit. The XML APIs in the
browser are comparitively clumsy and the
natural mapping from JavaScript objects to
JSON eliminates the serialization issues that
arise if you’re careless with XML.
One line of argument for JSON over XML is
simplicity. If you mean it’s simpler to have a
single data interchange format instead of two,
that’s incontrovertibly the case. If you mean
JSON is intrinsically simpler than XML, well,
I’m not sure that’s so obvious. For bundles of
atomic values, it’s a little simpler. And the
JavaScript APIs are definitely simpler. But I’ve
seen attempts to represent mixed content in
JSON and simple they aren’t.
XML
XML deals remarkably well with the full
richness of unstructured data. I’m not worried
about the future of XML at all even if its death
is gleefully celebrated by a cadre of web API
designers.
I look forward to seeing what the JSON folks
do when they are asked to develop richer
APIs. When they want to exchange less well
strucured data, will they shoehorn it into
JSON? I see occasional mentions of a schema
language for JSON, will other languages
follow?
I predict there will come a day when someone
wants to federate JSON data across several
application domains. I wonder, when they
discover that the key "width" means different
things to different constituencies, will they
invent namespaces too?
JSON AND HYPERMEDIA
HAL Media Types
HAL and Links
HAL and Resources
HAL Embedded Resources
ERROR HANDLING
WHY STATUS CODES AREN’T ENOUGH?
A status code simply isn’t enough information most of the
time. Yes, you want to define standard status codes so that
your clients can perform reasonable branching, but you also
need a way to communicate details to the end-user, so that
they can log the information for themselves, display
information to their own end-users, and/or report it back to
you so you can do something to resolve the situation.
SOURCESRESTful Web Services
Microsoft REST Spec
Amazon's HMAC-SHA
HTTP Method Definitions
JSON and REST presentation
HAL Specification
THE END
Sławomir Chrobak /
Link to presentation:
@schrobak
http://schrobak.github.io/slides/tgor

More Related Content

What's hot

UNIT III - MUSIC OF MINDANAO.pptx
UNIT III - MUSIC OF MINDANAO.pptxUNIT III - MUSIC OF MINDANAO.pptx
UNIT III - MUSIC OF MINDANAO.pptx
HaydeeCarpizo
 
FESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptx
FESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptxFESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptx
FESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptx
BrizielAtchico
 
3 music lm q1
3 music lm q13 music lm q1
3 music lm q1
EDITHA HONRADEZ
 
musicofmindanao-181006161124.pptx
musicofmindanao-181006161124.pptxmusicofmindanao-181006161124.pptx
musicofmindanao-181006161124.pptx
GENIVACANDA2
 
Music 7 Module (1 st quarter)
Music 7 Module (1 st quarter)Music 7 Module (1 st quarter)
Music 7 Module (1 st quarter)
Jarmanne
 
K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)
K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)
K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)
LiGhT ArOhL
 

What's hot (6)

UNIT III - MUSIC OF MINDANAO.pptx
UNIT III - MUSIC OF MINDANAO.pptxUNIT III - MUSIC OF MINDANAO.pptx
UNIT III - MUSIC OF MINDANAO.pptx
 
FESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptx
FESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptxFESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptx
FESTIVALS AND THEATER ARTS OF CHINA JAPAN AND.pptx
 
3 music lm q1
3 music lm q13 music lm q1
3 music lm q1
 
musicofmindanao-181006161124.pptx
musicofmindanao-181006161124.pptxmusicofmindanao-181006161124.pptx
musicofmindanao-181006161124.pptx
 
Music 7 Module (1 st quarter)
Music 7 Module (1 st quarter)Music 7 Module (1 st quarter)
Music 7 Module (1 st quarter)
 
K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)
K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)
K TO 12 GRADE 7 LEARNING MODULE IN MUSIC (Q1-Q2)
 

Similar to The Glory of Rest

Rest web service
Rest web serviceRest web service
Rest web service
Hamid Ghorbani
 
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Jackson F. de A. Mafra
 
Automating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight SemanticsAutomating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight Semantics
mmaleshkova
 
SCDJWS 6. REST JAX-P
SCDJWS 6. REST  JAX-PSCDJWS 6. REST  JAX-P
SCDJWS 6. REST JAX-P
Francesco Ierna
 
Unit 2
Unit 2Unit 2
Unit 2
Ravi Kumar
 
Advanced soa and web services
Advanced soa and web servicesAdvanced soa and web services
Advanced soa and web services
Sreekanth Narayanan
 
RIA Data and Security, 2007
RIA Data and Security, 2007RIA Data and Security, 2007
RIA Data and Security, 2007
Evgenios Skitsanos
 
Open Calais
Open CalaisOpen Calais
Open Calais
ymark
 
Document Databases & RavenDB
Document Databases & RavenDBDocument Databases & RavenDB
Document Databases & RavenDB
Brian Ritchie
 
SemanticWeb Nuts 'n Bolts
SemanticWeb Nuts 'n BoltsSemanticWeb Nuts 'n Bolts
SemanticWeb Nuts 'n Bolts
Rinke Hoekstra
 
SFDC REST API
SFDC REST APISFDC REST API
SFDC REST API
Bohdan Dovhań
 
Web services for developer
Web services for developerWeb services for developer
Web services for developer
Rafiq Ahmed
 
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISThe glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
Geert Pante
 
Building social and RESTful frameworks
Building social and RESTful frameworksBuilding social and RESTful frameworks
Building social and RESTful frameworks
brendonschwartz
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
Sreeni I
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
deimos
 
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
CA API Management
 
All about elasticsearch language clients
All about elasticsearch language clientsAll about elasticsearch language clients
All about elasticsearch language clients
Enterprise Search Warsaw Meetup
 
WIT UNIT-5.pdf
WIT UNIT-5.pdfWIT UNIT-5.pdf
WIT UNIT-5.pdf
jashmithakakavakam
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
shanmukhareddy dasi
 

Similar to The Glory of Rest (20)

Rest web service
Rest web serviceRest web service
Rest web service
 
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015
 
Automating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight SemanticsAutomating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight Semantics
 
SCDJWS 6. REST JAX-P
SCDJWS 6. REST  JAX-PSCDJWS 6. REST  JAX-P
SCDJWS 6. REST JAX-P
 
Unit 2
Unit 2Unit 2
Unit 2
 
Advanced soa and web services
Advanced soa and web servicesAdvanced soa and web services
Advanced soa and web services
 
RIA Data and Security, 2007
RIA Data and Security, 2007RIA Data and Security, 2007
RIA Data and Security, 2007
 
Open Calais
Open CalaisOpen Calais
Open Calais
 
Document Databases & RavenDB
Document Databases & RavenDBDocument Databases & RavenDB
Document Databases & RavenDB
 
SemanticWeb Nuts 'n Bolts
SemanticWeb Nuts 'n BoltsSemanticWeb Nuts 'n Bolts
SemanticWeb Nuts 'n Bolts
 
SFDC REST API
SFDC REST APISFDC REST API
SFDC REST API
 
Web services for developer
Web services for developerWeb services for developer
Web services for developer
 
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISThe glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
 
Building social and RESTful frameworks
Building social and RESTful frameworksBuilding social and RESTful frameworks
Building social and RESTful frameworks
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
 
All about elasticsearch language clients
All about elasticsearch language clientsAll about elasticsearch language clients
All about elasticsearch language clients
 
WIT UNIT-5.pdf
WIT UNIT-5.pdfWIT UNIT-5.pdf
WIT UNIT-5.pdf
 
Ruby on rails for beginers
Ruby on rails for beginersRuby on rails for beginers
Ruby on rails for beginers
 

Recently uploaded

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 

Recently uploaded (20)

HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 

The Glory of Rest

  • 4. WEB SERVICE A web service is an abstraction layer, like an operating system API or a programming language library.
  • 5. RPC-STYLE ARCHITECTURES envelope full of data HTTP and SOAP are envelope formats RPC-Style service defines it's own vocabulary RESTful WS share standard HTTP methods vocabulary REST Uniform Interface
  • 6. RESTful - different URIs for different values RPC-style - URI (service endpoint) for something that can be processed as a command
  • 7. REST-RPC HYBRID ARCHITECTURES Web service between the RESTful web services and the purely RPC-style services
  • 8. FEW REST-RPC EXAMPLES The The "REST" Many other allegedly RESTful web services Most web applications del.icio.us API Flickr web API
  • 9. SOAP AS A COMPETITOR TO REST The primary competitors to RESTful architectures are RPC architectures, not specific technologies like SOAP.
  • 10. RICHARDSON MATURITY MODEL Source: http://martinfowler.com
  • 11. LEVEL 0 - THE SWAMP OF POX HTTP POST for all interactions
  • 12. LEVEL 1 - RESOURCES Distinct URL per object
  • 13. LEVEL 2 - HTTP VERBS Rather than doing RPC style methods, we leverage HTTP
  • 14. LEVEL 3 - HYPERMEDIA CONTROLS Self-describing API
  • 15. SO WHAT IS THIS REST THING? REST simply dictates that a given resource have a unique address. You can interact with that address with standard HTTP verbs.
  • 17. TWO TYPES OF STATE: 1. application state - live on the client 2. resource state - live on the server
  • 18. Resource state stays on the server and is only sent to the client in the form of representations. Application state stays on the client until it can be used to create, modify, or delete a resource. Then it's sent to the server as part of POST, PUT, or DELETE request, and becomes resource state. RESTful service is "stateless" if the server never stores any application state.
  • 19. This is where the name "Representational State Transfer" comes from.
  • 20. ETAGS ETags are used to compare entities from the same resource. By supplying an entity tag value in a conditional request header.
  • 21. RESOURCE-ORIENTED BASICS different audience everything (interesting) thing represent as a resource representation of resources verbs, auxiliaries, complexity
  • 22. THE GENERIC ROA PROCEDURE 1. Figure out the data set 2. Split the data set into resources For each kind of resource: 3. Name the resources with URIs 4. Expose a subset of the uniform interface 5. Design the representation(s) accepted from the client 6. Design the representation(s) served to the client 7. Integrate this resource into existing resources, using hypermedia links and forms 8. Consider the typical course of events: what’s supposed to happen? Standard control flows like the Atom Publishing Protocol can help. 9. Consider error conditions: what might go wrong? Again, standard control flows can help.
  • 23.
  • 26.
  • 28. GET, PUT, AND DELETE
  • 29. POST
  • 30. HEAD AND OPTIONS Retrieve a metadata-only representation: HTTP HEAD Check which HTTP methods a particular resource supports: HTTP OPTIONS
  • 32. OVERLOADING POST The real information may be in the URI, the HTTP headers, or the entity-body. However it happens, an element of the RPC style has crept into the service.
  • 33. SAFETY AND IDEMPOTENCE When correctly used, GET and HEAD requests are safe. GET, HEAD, PUT and DELETE requests are idempotent.
  • 34. URI DESING URIs are supposed to designate resources, not operations on the resources.
  • 35. MethodMethod URI TemplateURI Template Equivalent RPCEquivalent RPC OperationOperation PUT users/{username} createUserAccount GET users/{username} getUserAccount PUT users/{username} updateUserAccount DELETE users/{username} deleteUserAccount GET users/{username}/profile getUserProfile POST users/{username}/bookmarks createBookmark PUT users/{username}/bookmarks/{id} updateBookmark DELETE users/{username}/bookmarks/{id} deleteBookmark GET users/{username}/bookmarks/{id} getBookmark GET users/{username}/bookmarks?tag= {tag} getUserBookmarks GET {username}?tag={tag} getUserPublicBookmarks GET ?tag={tag} getPublicBookmarks
  • 36. Use commas when the order of the items matters, as it does in latitude and longitude: /earth/37.0,-95.2 Use semicolons when the order doesn’t matter: /color- blends/red;blue When designing URIs, use path variables to separate elements of a hierarchy, or a path through a directed graph. Use query variables only to suggest arguments being plugged into an algorithm, or when the other two techniques fail.
  • 37. REPRESENTATIONS Representations should be human-readable, but computer-oriented
  • 38. SERVICE VERSIONING Even a well-connected service might need to be versioned
  • 39. SECURITY HMAC "Authorization: AWS " + AWSAccessKeyId+ ":" + base64(hmac-sha1(VERB + "n" + CONTENT-MD5 + "n" + CONTENT-TYPE + "n" + DATE + "n" + CanonicalizedAmzHeaders + "n" + CanonicalizedResource)) Authorization: AWS 44CF9590006BF252F707:jZNOcbfWmD/A/f3hSvVzXZjM2HU=
  • 41. JSON
  • 42. If all you want to pass around are atomic values or lists or hashes of atomic values, JSON has many of the advantages of XML: it’s straightforwardly usable over the Internet, supports a wide variety of applications, it’s easy to write programs to process JSON, it has few optional features, it’s human-legible and reasonably clear, its design is formal and concise, JSON documents are easy to create, and it uses Unicode.
  • 43. If you’re writing JavaScript in a web browser, JSON is a natural fit. The XML APIs in the browser are comparitively clumsy and the natural mapping from JavaScript objects to JSON eliminates the serialization issues that arise if you’re careless with XML.
  • 44. One line of argument for JSON over XML is simplicity. If you mean it’s simpler to have a single data interchange format instead of two, that’s incontrovertibly the case. If you mean JSON is intrinsically simpler than XML, well, I’m not sure that’s so obvious. For bundles of atomic values, it’s a little simpler. And the JavaScript APIs are definitely simpler. But I’ve seen attempts to represent mixed content in JSON and simple they aren’t.
  • 45. XML
  • 46. XML deals remarkably well with the full richness of unstructured data. I’m not worried about the future of XML at all even if its death is gleefully celebrated by a cadre of web API designers.
  • 47. I look forward to seeing what the JSON folks do when they are asked to develop richer APIs. When they want to exchange less well strucured data, will they shoehorn it into JSON? I see occasional mentions of a schema language for JSON, will other languages follow?
  • 48. I predict there will come a day when someone wants to federate JSON data across several application domains. I wonder, when they discover that the key "width" means different things to different constituencies, will they invent namespaces too?
  • 49. JSON AND HYPERMEDIA HAL Media Types HAL and Links HAL and Resources HAL Embedded Resources
  • 50. ERROR HANDLING WHY STATUS CODES AREN’T ENOUGH?
  • 51. A status code simply isn’t enough information most of the time. Yes, you want to define standard status codes so that your clients can perform reasonable branching, but you also need a way to communicate details to the end-user, so that they can log the information for themselves, display information to their own end-users, and/or report it back to you so you can do something to resolve the situation.
  • 52. SOURCESRESTful Web Services Microsoft REST Spec Amazon's HMAC-SHA HTTP Method Definitions JSON and REST presentation HAL Specification
  • 53. THE END Sławomir Chrobak / Link to presentation: @schrobak http://schrobak.github.io/slides/tgor