SlideShare a Scribd company logo
1 of 30
Download to read offline
REST
na pravi način
Hrvoje Crnjak
Pet minuta d.o.o.
How RESTful is My
REST ?
FIVE
Krenimo od početka...
● HTTP/0.9 (1991)
– Protokol ne zadovoljava potrebe
● Kako odrediti što nedostaje?
– Potrebno definirati model kako bi Web trebao raditi
● Odgovor
– “HTTP object model”
– Zbog imena pogrešno tumačen kao model
implementacije HTTP servera
FIVE
I bi REST
● REpresentational State Transfer
● Odgovor na potrebu za modelom Weba
● Razvijen od strane grupa za razvoj HTTP protokola
– Glavni kreator Roy Thomas Fielding
● Prva primjena
– HTTP/1.0 (1994)
● Objavljen
– Doktorska disertacija Roya Fieldinga (2000)
FIVE
REST službeno
● Koordinirani skup arhitekturalnih ograničenja s
ciljem minimiziranja latencije i generalne mrežne
komunikacije, te maksimiziranja nezavisnosti i
skalabilnosti komponenata implementacije
● 6 ograničenja (constraint) čini REST stil arhitekture
FIVE
Client-Server
● Separation of concerns
● Rezultat
– Nezavisan razvoj komponenata
– Komponente pojednostavljene
FIVE
ServerClient
ServiceService Consumer
Stateless
● Server ne treba pamtiti stanje aplikacije
● Rezultat
– Klijent u svakom requestu šalje sve informacije potrebne za
izvršavanje istoga
● Posljedice
– Poboljšana efikasnost monitoring sustava
– Jednostavniji recovery
– Poboljšana skalabilnost servera (nema potrebe za pohranom
stanja)
– Session state u potpunosti čuvan na klijentu
– Network overhead
FIVE
Stateless
FIVE
Server
Client
Self-Described
Message with all
info needed for
operation
Client
Cache
● Podaci responsea označavaju su kao cacheable ili
non-cacheable
● Posljedice
– Poboljšana efikasnost, skalabilnost, te performanse iz
korisničke perspektive
– Smanjena pouzdanost (što ako je podatak zastario)
FIVE
ServerClient $
Cache will avoid
full trip to server
Uniform Interface
● Sve komponente arhitekture moraju dijeliti isto
tehničko sučelje
– Sučelje dovoljno generičko za primjenu na široki raspon
domena
● Prednost
– Sve komponente arhitekture “znaju” jezik komunikacije
● Mana
– Zbog standardiziranosti sučelja, smanjena efikasnost
FIVE
Uniform Interface
● Zahtjevi na izgled korisničkog sučelja :
– Identification of resources
– Manipulation of resources through representations
– Self descriptive messages
– Hypermedia as the engine of application state (HATEOAS)
FIVE
Layered System
●
Rješenje se može sastojati od više slojeva arhitekture
– Sloj ne može “vidjeti” dalje od idućega u “nizu”
– Manipulacija slojevima prema potrebi
●
Slučajevi uporabe
– Enkapsulacija legacy sustava
– Load balancing, shared cache
– Analiza i transformacija poruka
●
U praksi
– Proxy, gateway
FIVE
Layered System
FIVE
Interim
with new API
Client
Server
with legacy APIClient
Code on Demand
● Dozvoljava klijentu da dohvati i izvrši kod sa
servera
● Bazira se na web-based tehnologijama
– Browser plug-ins
– Applets
– Client-side scripting languages (JavaScript)
●
OPCIONALNO!
FIVE
Richardson Maturity Model
● Model za ocjenjivanje korisničkog API-ja prema
tome kako implementira zahtjeve REST arhitekture
● Autor
– Leonard Richardson
● Objavljen
– QCon konferencija 2008. god.
● 4 levela (0 – 3)
FIVE
Level 0 : The Swamp of POX
● Jedan URI
– Definira sve operacije (cjelokupnu funkcionalnost)
– Željena operacija navodi se u samoj poruci
● Jedan HTTP glagol
– Najčešće POST
● HTTP isključivo kao transportni protokol
– Tunneling mehanizam za vlastiti remote interaction
sustav (pr. SOAP)
FIVE
Level 0: The Swamp of POX
FIVE
Level 0: The Swamp of POX
FIVE
Level 0: The Swamp of POX
FIVE
Level 1 : Resources
● URI-ji definirani prema resursima aplikacije
● I dalje jedan HTTP glagol
● Divide and conquer metoda
– Veliki service endpoint lomi u više manjih (jednostavnijih)
resursa
FIVE
Level 1 : Resources
FIVE
Level 1 : Resources
FIVE
Level 2 : HTTP Verbs
● Više URI-ja
● HTTP glagoli i statusi koriste se kako su definirani
specifikacijom
● HTTP prestaje biti samo transportni protokol
– Koristi se standardni set glagola i statusa kako bi se slične
situacije rješavale na slične i predvidljive načine
(why reinvent the wheel)
FIVE
Level 2 : HTTP Verbs
FIVE
Level 2 : HTTP Verbs
FIVE
Level 2 : HTTP Verbs
FIVE
Level 3 : Hypermedia Controls
● HATEOAS
– Hypermedia as the Engine of Application State
● Svaki response sadrži popis akcija trenutno dopuštenih korisniku
● Prednosti
– Korisnik zna koje akcije smije izvršiti u datom trenutku
– Dodatni sloj indirekcije (lakše buduće promjene)
● “Mane”
– Network overhead
– Benefit vidljiv tek u long-termu
FIVE
Level 3 : Hypermedia Controls
FIVE
Level 3 : Hypermedia Controls
FIVE
Drugi pokušaj...
How RESTful is My
REST ?
Hvala NA Pažnji !
Pitanja ?
FIVE

More Related Content

Viewers also liked

Messagerie électronique presentation
Messagerie électronique presentationMessagerie électronique presentation
Messagerie électronique presentationSylvie Almodovar
 
Brand Content Strategy
Brand Content StrategyBrand Content Strategy
Brand Content StrategySolange Derrey
 
Les 10 Tendances Webdesign pour 2014 by Vanksen
Les 10 Tendances Webdesign pour 2014 by VanksenLes 10 Tendances Webdesign pour 2014 by Vanksen
Les 10 Tendances Webdesign pour 2014 by VanksenSolange Derrey
 
Redesign Château de Versailles : Equipe 14
Redesign Château de Versailles : Equipe 14Redesign Château de Versailles : Equipe 14
Redesign Château de Versailles : Equipe 14HETIC
 
Les entreprises ont-elles besoin d'un community manager- Gilles MARC
Les entreprises ont-elles besoin d'un community manager- Gilles MARCLes entreprises ont-elles besoin d'un community manager- Gilles MARC
Les entreprises ont-elles besoin d'un community manager- Gilles MARCGilles MARC
 
OASIS et la fin du monde - HETIC e1
OASIS et la fin du monde - HETIC e1OASIS et la fin du monde - HETIC e1
OASIS et la fin du monde - HETIC e1HETIC
 

Viewers also liked (20)

JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
 
HUJAK prezentacija - druženje 2012-04-03
HUJAK prezentacija - druženje 2012-04-03HUJAK prezentacija - druženje 2012-04-03
HUJAK prezentacija - druženje 2012-04-03
 
JavaCro'14 - Oracle intentions in Java area - Marin Tadić
JavaCro'14 - Oracle intentions in Java area - Marin TadićJavaCro'14 - Oracle intentions in Java area - Marin Tadić
JavaCro'14 - Oracle intentions in Java area - Marin Tadić
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
 
Začinite svoj Scrum - HUJAK - druženje 2013-07-10
Začinite svoj Scrum - HUJAK - druženje 2013-07-10Začinite svoj Scrum - HUJAK - druženje 2013-07-10
Začinite svoj Scrum - HUJAK - druženje 2013-07-10
 
Javantura Zagreb 2014 - Groovy-SQL - Dinko Srkoč
Javantura Zagreb 2014 - Groovy-SQL - Dinko SrkočJavantura Zagreb 2014 - Groovy-SQL - Dinko Srkoč
Javantura Zagreb 2014 - Groovy-SQL - Dinko Srkoč
 
Javantura Zagreb 2014 - Alfresco-Neo4j integracija - Damir Murat
Javantura Zagreb 2014 - Alfresco-Neo4j integracija - Damir MuratJavantura Zagreb 2014 - Alfresco-Neo4j integracija - Damir Murat
Javantura Zagreb 2014 - Alfresco-Neo4j integracija - Damir Murat
 
Javantura Zagreb 2014 - Vert.x 1.3 - Mihovil Rister
Javantura Zagreb 2014 - Vert.x 1.3 - Mihovil RisterJavantura Zagreb 2014 - Vert.x 1.3 - Mihovil Rister
Javantura Zagreb 2014 - Vert.x 1.3 - Mihovil Rister
 
Javantura Zagreb 2014 - Vaadin - Peter Lehto
Javantura Zagreb 2014 - Vaadin - Peter LehtoJavantura Zagreb 2014 - Vaadin - Peter Lehto
Javantura Zagreb 2014 - Vaadin - Peter Lehto
 
Javantura v2 - Morphia - painfree JPA for MongoDB - Philipp Krenn
Javantura v2 - Morphia - painfree JPA for MongoDB - Philipp KrennJavantura v2 - Morphia - painfree JPA for MongoDB - Philipp Krenn
Javantura v2 - Morphia - painfree JPA for MongoDB - Philipp Krenn
 
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan PeshovJavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
 
Messagerie électronique presentation
Messagerie électronique presentationMessagerie électronique presentation
Messagerie électronique presentation
 
Atelier 13 - Réenchanter les destinations pour conquérir et transformer - ET8
Atelier 13 - Réenchanter les destinations pour conquérir et transformer - ET8Atelier 13 - Réenchanter les destinations pour conquérir et transformer - ET8
Atelier 13 - Réenchanter les destinations pour conquérir et transformer - ET8
 
Brand Content Strategy
Brand Content StrategyBrand Content Strategy
Brand Content Strategy
 
ET12 - EX4 - Google adwords
ET12 - EX4 - Google adwordsET12 - EX4 - Google adwords
ET12 - EX4 - Google adwords
 
Les 10 Tendances Webdesign pour 2014 by Vanksen
Les 10 Tendances Webdesign pour 2014 by VanksenLes 10 Tendances Webdesign pour 2014 by Vanksen
Les 10 Tendances Webdesign pour 2014 by Vanksen
 
A12 reporters de territoires - #et9
A12 reporters de territoires - #et9A12 reporters de territoires - #et9
A12 reporters de territoires - #et9
 
Redesign Château de Versailles : Equipe 14
Redesign Château de Versailles : Equipe 14Redesign Château de Versailles : Equipe 14
Redesign Château de Versailles : Equipe 14
 
Les entreprises ont-elles besoin d'un community manager- Gilles MARC
Les entreprises ont-elles besoin d'un community manager- Gilles MARCLes entreprises ont-elles besoin d'un community manager- Gilles MARC
Les entreprises ont-elles besoin d'un community manager- Gilles MARC
 
OASIS et la fin du monde - HETIC e1
OASIS et la fin du monde - HETIC e1OASIS et la fin du monde - HETIC e1
OASIS et la fin du monde - HETIC e1
 

More from HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association

More from HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association (20)

Java cro'21 the best tools for java developers in 2021 - hujak
Java cro'21   the best tools for java developers in 2021 - hujakJava cro'21   the best tools for java developers in 2021 - hujak
Java cro'21 the best tools for java developers in 2021 - hujak
 
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK KeynoteJavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
 
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan LozićJavantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
 
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
 
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
 
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander RadovanJavantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
 
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
 
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
 
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
 
Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...
 
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej VidakovićJavantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
 
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
 
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
 
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
 
Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...
 
Javantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela PetracJavantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela Petrac
 
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje RuhekJavantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
 
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
 
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario KusekJavantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
 

JavaCro'15 - Doing it RESTfully - Hrvoje Crnjak

  • 1. REST na pravi način Hrvoje Crnjak Pet minuta d.o.o.
  • 2. How RESTful is My REST ? FIVE
  • 3. Krenimo od početka... ● HTTP/0.9 (1991) – Protokol ne zadovoljava potrebe ● Kako odrediti što nedostaje? – Potrebno definirati model kako bi Web trebao raditi ● Odgovor – “HTTP object model” – Zbog imena pogrešno tumačen kao model implementacije HTTP servera FIVE
  • 4. I bi REST ● REpresentational State Transfer ● Odgovor na potrebu za modelom Weba ● Razvijen od strane grupa za razvoj HTTP protokola – Glavni kreator Roy Thomas Fielding ● Prva primjena – HTTP/1.0 (1994) ● Objavljen – Doktorska disertacija Roya Fieldinga (2000) FIVE
  • 5. REST službeno ● Koordinirani skup arhitekturalnih ograničenja s ciljem minimiziranja latencije i generalne mrežne komunikacije, te maksimiziranja nezavisnosti i skalabilnosti komponenata implementacije ● 6 ograničenja (constraint) čini REST stil arhitekture FIVE
  • 6. Client-Server ● Separation of concerns ● Rezultat – Nezavisan razvoj komponenata – Komponente pojednostavljene FIVE ServerClient ServiceService Consumer
  • 7. Stateless ● Server ne treba pamtiti stanje aplikacije ● Rezultat – Klijent u svakom requestu šalje sve informacije potrebne za izvršavanje istoga ● Posljedice – Poboljšana efikasnost monitoring sustava – Jednostavniji recovery – Poboljšana skalabilnost servera (nema potrebe za pohranom stanja) – Session state u potpunosti čuvan na klijentu – Network overhead FIVE
  • 9. Cache ● Podaci responsea označavaju su kao cacheable ili non-cacheable ● Posljedice – Poboljšana efikasnost, skalabilnost, te performanse iz korisničke perspektive – Smanjena pouzdanost (što ako je podatak zastario) FIVE ServerClient $ Cache will avoid full trip to server
  • 10. Uniform Interface ● Sve komponente arhitekture moraju dijeliti isto tehničko sučelje – Sučelje dovoljno generičko za primjenu na široki raspon domena ● Prednost – Sve komponente arhitekture “znaju” jezik komunikacije ● Mana – Zbog standardiziranosti sučelja, smanjena efikasnost FIVE
  • 11. Uniform Interface ● Zahtjevi na izgled korisničkog sučelja : – Identification of resources – Manipulation of resources through representations – Self descriptive messages – Hypermedia as the engine of application state (HATEOAS) FIVE
  • 12. Layered System ● Rješenje se može sastojati od više slojeva arhitekture – Sloj ne može “vidjeti” dalje od idućega u “nizu” – Manipulacija slojevima prema potrebi ● Slučajevi uporabe – Enkapsulacija legacy sustava – Load balancing, shared cache – Analiza i transformacija poruka ● U praksi – Proxy, gateway FIVE
  • 13. Layered System FIVE Interim with new API Client Server with legacy APIClient
  • 14. Code on Demand ● Dozvoljava klijentu da dohvati i izvrši kod sa servera ● Bazira se na web-based tehnologijama – Browser plug-ins – Applets – Client-side scripting languages (JavaScript) ● OPCIONALNO! FIVE
  • 15. Richardson Maturity Model ● Model za ocjenjivanje korisničkog API-ja prema tome kako implementira zahtjeve REST arhitekture ● Autor – Leonard Richardson ● Objavljen – QCon konferencija 2008. god. ● 4 levela (0 – 3) FIVE
  • 16. Level 0 : The Swamp of POX ● Jedan URI – Definira sve operacije (cjelokupnu funkcionalnost) – Željena operacija navodi se u samoj poruci ● Jedan HTTP glagol – Najčešće POST ● HTTP isključivo kao transportni protokol – Tunneling mehanizam za vlastiti remote interaction sustav (pr. SOAP) FIVE
  • 17. Level 0: The Swamp of POX FIVE
  • 18. Level 0: The Swamp of POX FIVE
  • 19. Level 0: The Swamp of POX FIVE
  • 20. Level 1 : Resources ● URI-ji definirani prema resursima aplikacije ● I dalje jedan HTTP glagol ● Divide and conquer metoda – Veliki service endpoint lomi u više manjih (jednostavnijih) resursa FIVE
  • 21. Level 1 : Resources FIVE
  • 22. Level 1 : Resources FIVE
  • 23. Level 2 : HTTP Verbs ● Više URI-ja ● HTTP glagoli i statusi koriste se kako su definirani specifikacijom ● HTTP prestaje biti samo transportni protokol – Koristi se standardni set glagola i statusa kako bi se slične situacije rješavale na slične i predvidljive načine (why reinvent the wheel) FIVE
  • 24. Level 2 : HTTP Verbs FIVE
  • 25. Level 2 : HTTP Verbs FIVE
  • 26. Level 2 : HTTP Verbs FIVE
  • 27. Level 3 : Hypermedia Controls ● HATEOAS – Hypermedia as the Engine of Application State ● Svaki response sadrži popis akcija trenutno dopuštenih korisniku ● Prednosti – Korisnik zna koje akcije smije izvršiti u datom trenutku – Dodatni sloj indirekcije (lakše buduće promjene) ● “Mane” – Network overhead – Benefit vidljiv tek u long-termu FIVE
  • 28. Level 3 : Hypermedia Controls FIVE
  • 29. Level 3 : Hypermedia Controls FIVE
  • 30. Drugi pokušaj... How RESTful is My REST ? Hvala NA Pažnji ! Pitanja ? FIVE