SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Stargate
An interstellar journey to restful APIs
Sponsored by
Hello!
I AM JUAN ESCALADA
Software Developer @ Mercap Software
2
Agenda
⋆ Intro
⋆ Features
⋆ Architecture
⋆ Live Demo
⋆ Conclusion
⋆ Future Work
3
Intro
What’s Stargate?
It is an MIT-licensed library supporting the
creation of HTTP based RESTful APIs…
ba-st/Stargate
What’s Stargate?
… built on top of Zinc HTTP components and Teapot
⋆ Zinc is used as HTTP Server
⋆ Teapot is used for routing
5
rest
6
L3
HATEOAS
L2
Multiple URIs
Multiple Verbs
L0
One URI
One Verb
Richardson Maturity Model
L1
Multiple URIs
One Verb
Principles
⋆ Client-Server
⋆ Stateless
⋆ Cacheable
⋆ Uniform interface
⋆ Layered system
Example: Pet store
7
Supported media types
⋆ application/vnd.stargate.pet+json;version=1.0.0
⋆ application/vnd.stargate.pet+json;version=1.1.0
⋆ application/vnd.stargate.pet+json;version=2.0.0
⋆ application/vnd.stargate.pet.summary+json;version=1.0.0
Available endpoints
⋆ /pets
⋆ GET
⋆ POST
⋆ OPTIONS
⋆ /orders
⋆ POST
⋆ OPTIONS
Features
8
Features
Content Negotiation HATEOAS
Hypertext as the Engine of
Application State
Caching control
9
Pagination CORS
Cross Origin Resource Sharing
Error Handling
Health check
Metrics
Content negotiation
Supported media types
⋆ application/vnd.stargate.pet+json;version=1.0.0
⋆ application/vnd.stargate.pet+json;version=1.1.0
⋆ application/vnd.stargate.pet+json;version=2.0.0
⋆ application/vnd.stargate.pet.summary+json;version=1.0.0
10
Accept: Content Type:
application/vnd.stargate.pet+json;version=1.0.0 application/vnd.stargate.pet+json;version=1.0.0
*/* application/vnd.stargate.pet+json;version=2.0.0
application/vnd.stargate.pet.summary+json application/vnd.stargate.pet.summary+json;version=1.0.0
application/xml 406/Not Acceptable
11
Content negotiation
Supported media types
⋆ application/vnd.stargate.pet+json;version=1.0.0
⋆ application/vnd.stargate.pet+json;version=1.1.0
⋆ application/vnd.stargate.pet+json;version=2.0.0
⋆ application/vnd.stargate.pet.summary+json;version=1.0.0
Accept: Content Type:
application/vnd.stargate.pet+json;version=1 application/vnd.stargate.pet+json;version=1.1.0
application/vnd.stargate.pet+json;version=1.0 application/vnd.stargate.pet+json;version=1.0.0
application/json;version=2 application/vnd.stargate.pet+json;version=2.0.0
application/vnd.stargate.pet+json;version=2 application/vnd.stargate.pet+json;version=2.0.0
HATEOAS
{
"pet": "1", "date": "2018-10-24T18:05:46.418Z", "status": "registered",
"links": {
"complete": "https://petstore.example.com/orders/1/complete",
"self": "https://petstore.example.com/orders/1",
"cancel": "https://petstore.example.com/orders/1/cancel"
}
}
12
Hypermedia as the Engine of Application State
Caching Control
⋆ ETags are generated on 200/OK 201/Created responses
⋆ When If-None-Match header is present in a GET a 304/Not Modified response
is created
⋆ Updates/deletes automatically raise a 428/Precondition required error when
If-Match header is missing
⋆ When If-Match header is present a 412/Precondition Failed error is raised if
the ETag doesn’t match
13
Error Handling
“Stargate, we have a problem”
Stargate will handle common error situations and produce
the corresponding responses:
⋆ 400/Bad Request on invalid or missing query parameters or
decoding errors
⋆ 404/Not Found when the resource lookup fails
⋆ 409/Conflict when the resource to update/create conflicts
with another one
⋆ 415/Unsupported media type when the Content Type cannot
be handled
14
Metrics
⋆ Endpoint: /metrics
⋆ Allowed HTTP methods: GET
⋆ Supported media types:
⋆ text/plain: In prometheus client data exposition format
⋆ text/vnd.stargate.prometheus.client-data-exposition;version=0.0.4
⋆ application/vnd.stargate.operational-metrics+json
⋆ Authentication: Required
⋆ Authorization: Requires read:metrics
⋆ Expected Responses: 200 OK
15
Health Check
⋆ Endpoint: /health-check
⋆ Allowed HTTP methods: POST
⋆ Supported media types:
⋆ application/vnd.stargate.health-check.details+json
⋆ application/vnd.stargate.health-check.summary+json
⋆ Authentication: Required
⋆ Expected Responses:
⋆ 200 OK if the overall health condition is not critical
⋆ 503 Service Unavailable if the overall health condition is critical
16
Architecture
17
18
Zinc Server
Teapot Server
/pets
/pets/{id}
/orders
/orders/{id}/comments
/currencies
ResourceRESTfulController
PetsRESTfulController
OrdersRESTfulController
CurrenciesRESTfulController
requestHandler
ordersRequestHandler
commentsRequestHandler
requestHandlerHTTP
Requests
HTTPBasedRESTfulAPI
Live Demo
19
Conclusions
Stargate is a good option if:
⋆ You want to implement an hypermedia driven API
⋆ You need advanced content negotiation
⋆ Or just need a way to structure your complex HTTP
REST API
20
Future Work
⋆ Improve cache control support: cache-control
directives, Last-Modified and Expires
⋆ Operational plugins
⋆ Configuration
⋆ Application Info
⋆ Application control
⋆ Loggers
21
22
Thanks!
ANY QUESTIONS?
j.escalada@mercapsoftware.com
ba-st/Stargate
Sponsored by
Credits
Special thanks to Mercap Software, the “Financial IT
Experts”, for sponsoring my trip and this presentation.
23

Contenu connexe

Similaire à Stargate: an interstellar journey to RESTful APIs

A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)
Danilo Sanchi
 
PHP Server side restful API - linkedin
PHP Server side restful API - linkedinPHP Server side restful API - linkedin
PHP Server side restful API - linkedin
Vũ Quang Sơn
 
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
lanslote
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
marvin337
 

Similaire à Stargate: an interstellar journey to RESTful APIs (20)

Connecting to Web Services on Android
Connecting to Web Services on AndroidConnecting to Web Services on Android
Connecting to Web Services on Android
 
A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)A simple ReSTful webservice for the Goblins (v. 0.5)
A simple ReSTful webservice for the Goblins (v. 0.5)
 
REST and Web API
REST and Web APIREST and Web API
REST and Web API
 
REST and Web API
REST and Web APIREST and Web API
REST and Web API
 
PHP Server side restful API - linkedin
PHP Server side restful API - linkedinPHP Server side restful API - linkedin
PHP Server side restful API - linkedin
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
Fulfilling the Hypermedia Constraint via HTTP OPTIONS, The HTTP Vocabulary In...
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
OGCE Project Overview
OGCE Project OverviewOGCE Project Overview
OGCE Project Overview
 
CrossRef How-to: A Technical Introduction to the Basics of CrossRef, Chuck Ko...
CrossRef How-to: A Technical Introduction to the Basics of CrossRef, Chuck Ko...CrossRef How-to: A Technical Introduction to the Basics of CrossRef, Chuck Ko...
CrossRef How-to: A Technical Introduction to the Basics of CrossRef, Chuck Ko...
 
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
[SharePoint Korea Conference 2013 / 강율구] Sharepoint 스마트하게 개발하기
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
So you think you know REST - DPC11
So you think you know REST - DPC11So you think you know REST - DPC11
So you think you know REST - DPC11
 
Spring MVC 3 Restful
Spring MVC 3 RestfulSpring MVC 3 Restful
Spring MVC 3 Restful
 
IMS Learning Tools Interoperability @ UCLA
IMS Learning Tools Interoperability @ UCLAIMS Learning Tools Interoperability @ UCLA
IMS Learning Tools Interoperability @ UCLA
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
 
Uni w pachube 111108
Uni w pachube 111108Uni w pachube 111108
Uni w pachube 111108
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
 
ReST-ful Resource Management
ReST-ful Resource ManagementReST-ful Resource Management
ReST-ful Resource Management
 

Plus de FAST

Powerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming LanguagesPowerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming Languages
FAST
 
Constructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden EngineConstructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden Engine
FAST
 
Demystifying the creation of coding tools
Demystifying the creation of coding toolsDemystifying the creation of coding tools
Demystifying the creation of coding tools
FAST
 
Application Starter: the entry point for your application
Application Starter: the entry point for your applicationApplication Starter: the entry point for your application
Application Starter: the entry point for your application
FAST
 
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
FAST
 
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the worldVASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
FAST
 
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting WorkshopHands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
FAST
 

Plus de FAST (20)

Threads, Critical Sections, and Termination
Threads, Critical Sections, and TerminationThreads, Critical Sections, and Termination
Threads, Critical Sections, and Termination
 
OOP with Smalltalk
OOP with SmalltalkOOP with Smalltalk
OOP with Smalltalk
 
Powerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming LanguagesPowerlang: a Vehicle for Lively Implementing Programming Languages
Powerlang: a Vehicle for Lively Implementing Programming Languages
 
Constructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden EngineConstructing 3D scenes with Woden Engine
Constructing 3D scenes with Woden Engine
 
Demystifying the creation of coding tools
Demystifying the creation of coding toolsDemystifying the creation of coding tools
Demystifying the creation of coding tools
 
Application Starter: the entry point for your application
Application Starter: the entry point for your applicationApplication Starter: the entry point for your application
Application Starter: the entry point for your application
 
Improving the Pharo VM
Improving the Pharo VMImproving the Pharo VM
Improving the Pharo VM
 
What is (not) Pharo 8?
What is (not) Pharo 8?What is (not) Pharo 8?
What is (not) Pharo 8?
 
Opening Smalltalks 2019
Opening Smalltalks 2019Opening Smalltalks 2019
Opening Smalltalks 2019
 
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção JrSmalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
Smalltalk Computers, Past and Future by Jecel Mattos de Assumpção Jr
 
Adaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção JrAdaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção Jr
 
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
Choosing where to run our objects: the S8 Smalltalk approach by Description:F...
 
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
Using 128 GPU cores, Tensorflow and VASmalltalk to detect Kolsh beers with ES...
 
Improving VASmalltalk deployment, availability and scalability with Docker by...
Improving VASmalltalk deployment, availability and scalability with Docker by...Improving VASmalltalk deployment, availability and scalability with Docker by...
Improving VASmalltalk deployment, availability and scalability with Docker by...
 
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the worldVASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
VASmalltalk and Raspberry Pi powering the largest MIDI instrument of the world
 
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting WorkshopHands-on Raspberry Pi and VA Smalltalk - Starting Workshop
Hands-on Raspberry Pi and VA Smalltalk - Starting Workshop
 
Live typing: Update and what's next by Hernan Wilkinson
Live typing: Update and what's next by Hernan WilkinsonLive typing: Update and what's next by Hernan Wilkinson
Live typing: Update and what's next by Hernan Wilkinson
 
Enhanced Email Protocol Framework for VAST by Seth Berman
Enhanced Email Protocol Framework for VAST by Seth BermanEnhanced Email Protocol Framework for VAST by Seth Berman
Enhanced Email Protocol Framework for VAST by Seth Berman
 
VA Smalltalk Product Update by Seth Berman
VA Smalltalk Product Update by Seth BermanVA Smalltalk Product Update by Seth Berman
VA Smalltalk Product Update by Seth Berman
 
Cuis Smalltalk: Past, present and future by By Hernán Wilkinson & Juan Vuletich
Cuis Smalltalk: Past, present and future by By Hernán Wilkinson & Juan VuletichCuis Smalltalk: Past, present and future by By Hernán Wilkinson & Juan Vuletich
Cuis Smalltalk: Past, present and future by By Hernán Wilkinson & Juan Vuletich
 

Dernier

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 

Stargate: an interstellar journey to RESTful APIs

  • 1. Stargate An interstellar journey to restful APIs Sponsored by
  • 2. Hello! I AM JUAN ESCALADA Software Developer @ Mercap Software 2
  • 3. Agenda ⋆ Intro ⋆ Features ⋆ Architecture ⋆ Live Demo ⋆ Conclusion ⋆ Future Work 3
  • 4. Intro What’s Stargate? It is an MIT-licensed library supporting the creation of HTTP based RESTful APIs… ba-st/Stargate
  • 5. What’s Stargate? … built on top of Zinc HTTP components and Teapot ⋆ Zinc is used as HTTP Server ⋆ Teapot is used for routing 5
  • 6. rest 6 L3 HATEOAS L2 Multiple URIs Multiple Verbs L0 One URI One Verb Richardson Maturity Model L1 Multiple URIs One Verb Principles ⋆ Client-Server ⋆ Stateless ⋆ Cacheable ⋆ Uniform interface ⋆ Layered system
  • 7. Example: Pet store 7 Supported media types ⋆ application/vnd.stargate.pet+json;version=1.0.0 ⋆ application/vnd.stargate.pet+json;version=1.1.0 ⋆ application/vnd.stargate.pet+json;version=2.0.0 ⋆ application/vnd.stargate.pet.summary+json;version=1.0.0 Available endpoints ⋆ /pets ⋆ GET ⋆ POST ⋆ OPTIONS ⋆ /orders ⋆ POST ⋆ OPTIONS
  • 9. Features Content Negotiation HATEOAS Hypertext as the Engine of Application State Caching control 9 Pagination CORS Cross Origin Resource Sharing Error Handling Health check Metrics
  • 10. Content negotiation Supported media types ⋆ application/vnd.stargate.pet+json;version=1.0.0 ⋆ application/vnd.stargate.pet+json;version=1.1.0 ⋆ application/vnd.stargate.pet+json;version=2.0.0 ⋆ application/vnd.stargate.pet.summary+json;version=1.0.0 10 Accept: Content Type: application/vnd.stargate.pet+json;version=1.0.0 application/vnd.stargate.pet+json;version=1.0.0 */* application/vnd.stargate.pet+json;version=2.0.0 application/vnd.stargate.pet.summary+json application/vnd.stargate.pet.summary+json;version=1.0.0 application/xml 406/Not Acceptable
  • 11. 11 Content negotiation Supported media types ⋆ application/vnd.stargate.pet+json;version=1.0.0 ⋆ application/vnd.stargate.pet+json;version=1.1.0 ⋆ application/vnd.stargate.pet+json;version=2.0.0 ⋆ application/vnd.stargate.pet.summary+json;version=1.0.0 Accept: Content Type: application/vnd.stargate.pet+json;version=1 application/vnd.stargate.pet+json;version=1.1.0 application/vnd.stargate.pet+json;version=1.0 application/vnd.stargate.pet+json;version=1.0.0 application/json;version=2 application/vnd.stargate.pet+json;version=2.0.0 application/vnd.stargate.pet+json;version=2 application/vnd.stargate.pet+json;version=2.0.0
  • 12. HATEOAS { "pet": "1", "date": "2018-10-24T18:05:46.418Z", "status": "registered", "links": { "complete": "https://petstore.example.com/orders/1/complete", "self": "https://petstore.example.com/orders/1", "cancel": "https://petstore.example.com/orders/1/cancel" } } 12 Hypermedia as the Engine of Application State
  • 13. Caching Control ⋆ ETags are generated on 200/OK 201/Created responses ⋆ When If-None-Match header is present in a GET a 304/Not Modified response is created ⋆ Updates/deletes automatically raise a 428/Precondition required error when If-Match header is missing ⋆ When If-Match header is present a 412/Precondition Failed error is raised if the ETag doesn’t match 13
  • 14. Error Handling “Stargate, we have a problem” Stargate will handle common error situations and produce the corresponding responses: ⋆ 400/Bad Request on invalid or missing query parameters or decoding errors ⋆ 404/Not Found when the resource lookup fails ⋆ 409/Conflict when the resource to update/create conflicts with another one ⋆ 415/Unsupported media type when the Content Type cannot be handled 14
  • 15. Metrics ⋆ Endpoint: /metrics ⋆ Allowed HTTP methods: GET ⋆ Supported media types: ⋆ text/plain: In prometheus client data exposition format ⋆ text/vnd.stargate.prometheus.client-data-exposition;version=0.0.4 ⋆ application/vnd.stargate.operational-metrics+json ⋆ Authentication: Required ⋆ Authorization: Requires read:metrics ⋆ Expected Responses: 200 OK 15
  • 16. Health Check ⋆ Endpoint: /health-check ⋆ Allowed HTTP methods: POST ⋆ Supported media types: ⋆ application/vnd.stargate.health-check.details+json ⋆ application/vnd.stargate.health-check.summary+json ⋆ Authentication: Required ⋆ Expected Responses: ⋆ 200 OK if the overall health condition is not critical ⋆ 503 Service Unavailable if the overall health condition is critical 16
  • 20. Conclusions Stargate is a good option if: ⋆ You want to implement an hypermedia driven API ⋆ You need advanced content negotiation ⋆ Or just need a way to structure your complex HTTP REST API 20
  • 21. Future Work ⋆ Improve cache control support: cache-control directives, Last-Modified and Expires ⋆ Operational plugins ⋆ Configuration ⋆ Application Info ⋆ Application control ⋆ Loggers 21
  • 23. Credits Special thanks to Mercap Software, the “Financial IT Experts”, for sponsoring my trip and this presentation. 23