SlideShare una empresa de Scribd logo
1 de 39
Understanding REST and designing for it RESTful Design
Robert MacLean www.sadev.co.za @rmaclean BB&D ATC Introduction HTTP Basics URI’s Methods Status Codes Content Type Authentication URI Planning Patterns Style Accidental Services Examples Actions Guidelines Anti-Patterns Security Wrap Up About me Agenda Welcome
REST Acronym?  Representational State Transfer  Source? Came about in 2000 doctoral dissertation of Roy Fielding
What is it? ROA – Resource Orientated Architecture WOA – Web Orientated Architecture Thanks Gartner for another TLA  It is a style NOT  API Interface Official Standard A drop in replacement for SOAP
Benefits of REST Highly scalable Designed for HTTP Easy to consume & produce No complex request/response model. No complex XML contracts Easy to understand for you and machines URI + Method = Intent
HTTP Basics REST builds on HTTP so you need to know HTTP HTTP is not HTML HTTP is stateless HTTP URI Header http://www.sadev.co.za Method GET Status Code 200 Content Type text/plain Body text
URI Basics Hostname Scheme Query http://www.sadev.co.za/users/1/contact http://www.sadev.co.za?user=1&action=contact http://rob:pass@bbd.co.za:8044 https://bbd.co.za/index.html#about Query Hostname Scheme Userinfo Hostname Port Scheme Scheme Hostname Query Fragment
Method Basics Just a guide
Status Codes 1xx – Informational  2xx – Success 3xx – Redirection 4xx – Client Error 5xx – Server Error
Status Codes Examples 100 = Continue 102 = Processing 200 = OK 201 = Created 204 = No Content 206 = Partial Content 301 = Moved Permanently  302 = Found (Moved Temp) 307 = Temp Redirect 400 = Bad Request 401 = Unauthorised 402 = Payment Required 403 = Forbidden 404 = Not Found 405 = Method Not Allowed 409 = Conflict 418 = I’m a teapot 450 = Blocked by Windows Parental Controls 500 = Internal Server Error 501 = Not Implemented
Content Type Proper name: Internet Media Type Also known as MIME type Parts: Type, SubType, Optional Parameters x- prefix for nonstandard types or subtypes vnd. prefix for vendor specific subtypes Frowned upon by purists
Content Type Examples text/plain 			– Plain text text/xml 			– XML  text/html 			– HTML  image/png 			– PNG image audio/basic 			– Wave audio audio/mpeg 			– MPEG audio (MP3) video/quicktime 			– Quicktime Video application/pdf 			– Adobe PDF document application/javascript 		– JavaScript application/vnd.ms-powerpoint 	– PowerPoint file application/x-rar-compressed 	– RAR file
HTTP Authentication Basic Authentication Easy to do, but plain text. Easy to reverse engineer. Less of an issue when used with SSL. Digest Authentication Harder to do, still plain text. Hard (impossible?) to reverse engineer because of hashing.  NTLM Authentication Hard to do, Windows specific. Hard (impossible?) to reverse engineer.
Header Example Request HEAD /index.html HTTP/1.1  Host: www.example.com  Response HTTP/1.1 200 OK  Date: Mon, 23 May 2005 22:38:34 GMT  Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)  Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT  Etag: "3f80f-1b6-3e1cb03b"  Accept-Ranges: bytes  Content-Length: 438  Connection: close  Content-Type: text/html; charset=UTF-8
Lego Catalogue A simple system to store what LEGO’s a person owns.  Want to Add bricks Set bricks status to be in use Remove bricks Get list of bricks Check if I have enough bricks Get picture of brick
Lego Catalogue URI HTTP Valid REST Valid Intent good
Lego Catalogue URI HTTP Valid REST Valid Intent good
Lego Catalogue URI HTTP Valid REST Valid Intent good
Lego Catalogue URI HTTP Valid REST Invalid Intent bad
Lego Catalogue URI HTTP Valid REST Invalid Intent nightmare
Real Life URI Example Resource: Photos Where: http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png) What: JPEG, GIF or PNG (defined in the URL) http://farm1.static.flickr.com/2/1418878_1e92283336_m.jpg
REST Method Style “The big four”
Accidental Services Accidental services do not use all methods Some URL’s offering all of them and others a limited set
Methods Example http://bbddb01/northwind/users[firstname=“rob%”] + POST = Error  + GET = Returns everyone who begins with rob + PUT = Error + DELETE = Deletes everyone who begins with rob http://bbddb01/northwind/users + we add some input data + POST = Creates a new user + GET = Returns everyone who meets criteria + PUT = Creates/Updates a user (based on data) + DELETE = Deletes everyone who meets criteria
Methods Example http://bbddb01/northwind/users[firstname=“rob%”] + POST = Error  + PUT = Error What would the error be? HTTP 400 would be best 405 or 500 could also be appropriate
What about actions? GetStoreOpenTime(Location) GET http://lc/stores/{location}/times?state=open RejectDesign(Design) POST http://lc/rejections + form data PerformBrickCount(Design) POST http://lc/design/124/brickCount GET http://lc/design/124/brickCount/2
Guidelines Design to be stateless Design for resources, not services Stock quote service vs. A way to work with stock resources Use cookies for self-contained state
Guidelines Naming: Favour nouns over verbs GET /brick/2/delete DELETE /brick/2 Shorter nice URI’s preferred, not required Do not change URI’s Use 3xx redirection if needed
Guidelines Give every resource an ID http://lc/brick/1 http://lc/project/planned/223 More URI’s the better
Guidelines Support for multiple data types or representations For data use XML and/or JSON Postfixes to define type GET /brick/2/image.jpg GET /brick/2/image.png
Guidelines Design with standards in mind – for example RSS & ATOM Create should return URI’s not resources Use the right HTTP methods for the right actions You are on HTTP – use the infrastructure. Proxy, Caching, Etag, Expires
Guidelines Hyperlinks are good <project self=“http://lc/project/753”>  <bricksUsed>    <brick ref=“http://lc/brick/234” />     <brick ref=“http://lc/brick/286” /> <brick ref=“http://lc/brick/12” />  </bricksUsed>  <coloursUsed>    <colour name=“red” code=“ff0000” ref=“http://lc/brick/red”/>   </coloursUsed> </project>
Guidelines Offer paging <bricks self=“http://lc/bricks”>  <link rel=“next” ref=“http://lc/bricks?page=20” />  … </bricks>
Guidelines Offer collections of information <bricks>  <brick ref=“http://lc/brick/1” />  <brick ref=“http://lc/brick/2” /> <brick ref=“http://lc/brick/3” /> </brick> <bricks>   <brick ref=“http://lc/brick/1”>     <colour>red</colour>  </brick>   <brick ref=“http://lc/brick/2”> <colour>red</colour>   </brick>   <brick ref=“http://lc/brick/3”> <colour>red</colour>   </brick> </brick>
Anti-Patterns Use one HTTP method – like GET for everything Often called GET or POST Tunnelling Pass everything in URI’s Assume this is a replacement for SOAP or WS*
Security101 Are RESTful services secure? It’s a style, not a technology so that depends on how you implement it. Are you open to SQL injection attacks? When you look at http://bbddb01/northwind/users[firstname=“rob%”], you may think so but you shouldn’t be. Because: The parameter shouldn’t be SQL If it is SQL, why are you not filtering it? Remember the old rule: Do not trust user input URI’s are user input
Security102 How can I do authentication? It’s built on HTTP, so everything you have for authentication in HTTP is available PLUS You could encode your authentication requirements into the input fields
Good Examples WCF Data Services Previously called ADO.NET Data Services & Astoria NerdDinner.com Twitter.com MediaWiki Their action’s are frowned upon by purists
Benefits of REST Highly scalable Designed for HTTP and stateless Easy to consume No complex request/response model. No complex XML contracts Easy to understand for you and machines URI + Method = Intent

Más contenido relacionado

La actualidad más candente

A Holistic View of Website Performance
A Holistic View of Website PerformanceA Holistic View of Website Performance
A Holistic View of Website PerformanceRene Churchill
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggetsguestbd1cdca
 
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?Andy Davies
 
The Case for HTTP/2 - EpicFEL Sept 2015
The Case for HTTP/2 - EpicFEL Sept 2015The Case for HTTP/2 - EpicFEL Sept 2015
The Case for HTTP/2 - EpicFEL Sept 2015Andy Davies
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMWoody Pewitt
 
The Future of the Web: HTML5
The Future of the Web: HTML5The Future of the Web: HTML5
The Future of the Web: HTML5Derek Bender
 
Html 5 in a big nutshell
Html 5 in a big nutshellHtml 5 in a big nutshell
Html 5 in a big nutshellLennart Schoors
 
HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & FriendsRemy Sharp
 
Getting the most out of WebPageTest
Getting the most out of WebPageTestGetting the most out of WebPageTest
Getting the most out of WebPageTestPatrick Meenan
 
Internet Explorer 8 for Developers by Christian Thilmany
Internet Explorer 8 for Developers by Christian ThilmanyInternet Explorer 8 for Developers by Christian Thilmany
Internet Explorer 8 for Developers by Christian ThilmanyChristian Thilmany
 
HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCMayflower GmbH
 
Los Angeles HTML5 User Group Meeting Ask the Expert Session
Los Angeles HTML5 User Group Meeting Ask the Expert SessionLos Angeles HTML5 User Group Meeting Ask the Expert Session
Los Angeles HTML5 User Group Meeting Ask the Expert SessionPeter Lubbers
 
HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]
HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]
HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]Aaron Gustafson
 
Pragmatics of Declarative Ajax
Pragmatics of Declarative AjaxPragmatics of Declarative Ajax
Pragmatics of Declarative Ajaxdavejohnson
 
What the heck is HTML 5?
What the heck is HTML 5?What the heck is HTML 5?
What the heck is HTML 5?Simon Willison
 
PHP Presentation
PHP PresentationPHP Presentation
PHP PresentationAnkush Jain
 

La actualidad más candente (20)

Html5 Overview
Html5 OverviewHtml5 Overview
Html5 Overview
 
A Holistic View of Website Performance
A Holistic View of Website PerformanceA Holistic View of Website Performance
A Holistic View of Website Performance
 
Joomla security nuggets
Joomla security nuggetsJoomla security nuggets
Joomla security nuggets
 
Speed Matters!
Speed Matters!Speed Matters!
Speed Matters!
 
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
 
The Case for HTTP/2 - EpicFEL Sept 2015
The Case for HTTP/2 - EpicFEL Sept 2015The Case for HTTP/2 - EpicFEL Sept 2015
The Case for HTTP/2 - EpicFEL Sept 2015
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAM
 
The Future of the Web: HTML5
The Future of the Web: HTML5The Future of the Web: HTML5
The Future of the Web: HTML5
 
Html 5 in a big nutshell
Html 5 in a big nutshellHtml 5 in a big nutshell
Html 5 in a big nutshell
 
HTML5 & Friends
HTML5 & FriendsHTML5 & Friends
HTML5 & Friends
 
Getting the most out of WebPageTest
Getting the most out of WebPageTestGetting the most out of WebPageTest
Getting the most out of WebPageTest
 
Internet Explorer 8 for Developers by Christian Thilmany
Internet Explorer 8 for Developers by Christian ThilmanyInternet Explorer 8 for Developers by Christian Thilmany
Internet Explorer 8 for Developers by Christian Thilmany
 
PHP
PHPPHP
PHP
 
HTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPCHTML5 for PHP Developers - IPC
HTML5 for PHP Developers - IPC
 
Los Angeles HTML5 User Group Meeting Ask the Expert Session
Los Angeles HTML5 User Group Meeting Ask the Expert SessionLos Angeles HTML5 User Group Meeting Ask the Expert Session
Los Angeles HTML5 User Group Meeting Ask the Expert Session
 
HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]
HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]
HTML5 Semantics, Accessibility & Forms [Carsonified HTML5 Online Conference]
 
Pragmatics of Declarative Ajax
Pragmatics of Declarative AjaxPragmatics of Declarative Ajax
Pragmatics of Declarative Ajax
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 
What the heck is HTML 5?
What the heck is HTML 5?What the heck is HTML 5?
What the heck is HTML 5?
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 

Destacado

Windows Server AppFabric
Windows Server AppFabricWindows Server AppFabric
Windows Server AppFabricRobert MacLean
 
Putting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestPutting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestRobert MacLean
 
Visual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptVisual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptRobert MacLean
 
DevConf Survival Guide
DevConf Survival GuideDevConf Survival Guide
DevConf Survival GuideRobert MacLean
 
Windows Server AppFabric Caching - What it is & when you should use it?
Windows Server AppFabric Caching - What it is & when you should use it?Windows Server AppFabric Caching - What it is & when you should use it?
Windows Server AppFabric Caching - What it is & when you should use it?Robert MacLean
 
Win8 architecture for developers
Win8 architecture for developersWin8 architecture for developers
Win8 architecture for developersRobert MacLean
 
Summer club
Summer clubSummer club
Summer clubMad Mary
 
Dia da mulher
Dia da mulherDia da mulher
Dia da mulhereecdda
 
Biarritz leblon
Biarritz leblonBiarritz leblon
Biarritz leblonMad Mary
 
Taller # 1 camilo
Taller # 1 camiloTaller # 1 camilo
Taller # 1 camilokamilo1997
 
Green park apresentação
Green park apresentaçãoGreen park apresentação
Green park apresentaçãoMad Mary
 
One Hundred and One Domatia
One Hundred and One DomatiaOne Hundred and One Domatia
One Hundred and One DomatiaAmy Luckhurst
 
Cálculo resistencia limitadora a diodo led
Cálculo resistencia limitadora a diodo ledCálculo resistencia limitadora a diodo led
Cálculo resistencia limitadora a diodo ledJohn Travolta
 

Destacado (20)

Enterprise Library 5
Enterprise Library 5Enterprise Library 5
Enterprise Library 5
 
Windows Server AppFabric
Windows Server AppFabricWindows Server AppFabric
Windows Server AppFabric
 
Sikuli
SikuliSikuli
Sikuli
 
.NET Reflection
.NET Reflection.NET Reflection
.NET Reflection
 
Putting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestPutting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/Test
 
Visual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptVisual Studio ❤ JavaScript
Visual Studio ❤ JavaScript
 
DevConf Survival Guide
DevConf Survival GuideDevConf Survival Guide
DevConf Survival Guide
 
Lightswitch
LightswitchLightswitch
Lightswitch
 
Windows Server AppFabric Caching - What it is & when you should use it?
Windows Server AppFabric Caching - What it is & when you should use it?Windows Server AppFabric Caching - What it is & when you should use it?
Windows Server AppFabric Caching - What it is & when you should use it?
 
Win8 architecture for developers
Win8 architecture for developersWin8 architecture for developers
Win8 architecture for developers
 
Summer club
Summer clubSummer club
Summer club
 
Ti
TiTi
Ti
 
Tipos de redes !
Tipos de redes !Tipos de redes !
Tipos de redes !
 
Thalia
ThaliaThalia
Thalia
 
Dia da mulher
Dia da mulherDia da mulher
Dia da mulher
 
Biarritz leblon
Biarritz leblonBiarritz leblon
Biarritz leblon
 
Taller # 1 camilo
Taller # 1 camiloTaller # 1 camilo
Taller # 1 camilo
 
Green park apresentação
Green park apresentaçãoGreen park apresentação
Green park apresentação
 
One Hundred and One Domatia
One Hundred and One DomatiaOne Hundred and One Domatia
One Hundred and One Domatia
 
Cálculo resistencia limitadora a diodo led
Cálculo resistencia limitadora a diodo ledCálculo resistencia limitadora a diodo led
Cálculo resistencia limitadora a diodo led
 

Similar a RESTful design

Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Tatsuhiko Miyagawa
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructureguest517f2f
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座Li Yi
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVCAlan Dean
 
Ruby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelRuby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelJiang Wu
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructurePamela Fox
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructureguest517f2f
 
Services web RESTful
Services web RESTfulServices web RESTful
Services web RESTfulgoldoraf
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Michiel Rook
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web ApplicationMartins Sipenko
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009marpierc
 
Revisiting HTTP/2
Revisiting HTTP/2Revisiting HTTP/2
Revisiting HTTP/2Fastly
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with seleniumSøren Lund
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website OptimizationGerard Sychay
 
GTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementationGTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementationDavid Calavera
 
How the web works june 2010
How the web works june 2010How the web works june 2010
How the web works june 2010Mark Carter
 

Similar a RESTful design (20)

WWW and HTTP
WWW and HTTPWWW and HTTP
WWW and HTTP
 
Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8Web Scraper Shibuya.pm tech talk #8
Web Scraper Shibuya.pm tech talk #8
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
Ruby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequelRuby off Rails---rack, sinatra and sequel
Ruby off Rails---rack, sinatra and sequel
 
Sword v2 at UKCoRR
Sword v2 at UKCoRRSword v2 at UKCoRR
Sword v2 at UKCoRR
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
Services web RESTful
Services web RESTfulServices web RESTful
Services web RESTful
 
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
HTTP Caching in Web Application
HTTP Caching in Web ApplicationHTTP Caching in Web Application
HTTP Caching in Web Application
 
HTTP Basics Demo
HTTP Basics DemoHTTP Basics Demo
HTTP Basics Demo
 
GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009GTLAB Installation Tutorial for SciDAC 2009
GTLAB Installation Tutorial for SciDAC 2009
 
Revisiting HTTP/2
Revisiting HTTP/2Revisiting HTTP/2
Revisiting HTTP/2
 
Basic testing with selenium
Basic testing with seleniumBasic testing with selenium
Basic testing with selenium
 
Front End Website Optimization
Front End Website OptimizationFront End Website Optimization
Front End Website Optimization
 
GTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementationGTAC: AtomPub, testing your server implementation
GTAC: AtomPub, testing your server implementation
 
How the web works june 2010
How the web works june 2010How the web works june 2010
How the web works june 2010
 

Más de Robert MacLean

14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)Robert MacLean
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPRobert MacLean
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find excitingRobert MacLean
 
The state of testing @ Microsoft
The state of testing @ MicrosoftThe state of testing @ Microsoft
The state of testing @ MicrosoftRobert MacLean
 
A Developer Day 2014 - Durban
A Developer Day 2014 - Durban A Developer Day 2014 - Durban
A Developer Day 2014 - Durban Robert MacLean
 
Agile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersAgile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersRobert MacLean
 
Hour of code - Train the trainer
Hour of code - Train the trainerHour of code - Train the trainer
Hour of code - Train the trainerRobert MacLean
 
Building services for apps on a shoestring budget
Building services for apps on a shoestring budgetBuilding services for apps on a shoestring budget
Building services for apps on a shoestring budgetRobert MacLean
 
3 things your app API is doing WRONG
3 things your app API is doing WRONG3 things your app API is doing WRONG
3 things your app API is doing WRONGRobert MacLean
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesRobert MacLean
 
Protection of Personal Information Bill (POPI)
Protection of Personal Information Bill (POPI)Protection of Personal Information Bill (POPI)
Protection of Personal Information Bill (POPI)Robert MacLean
 

Más de Robert MacLean (20)

14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)
 
Git
GitGit
Git
 
OWASP TOP 10
OWASP TOP 10OWASP TOP 10
OWASP TOP 10
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCP
 
Looking at the Vue
Looking at the VueLooking at the Vue
Looking at the Vue
 
Kotlin 101
Kotlin 101Kotlin 101
Kotlin 101
 
Features of Kotlin I find exciting
Features of Kotlin I find excitingFeatures of Kotlin I find exciting
Features of Kotlin I find exciting
 
JavaScript Gotchas
JavaScript GotchasJavaScript Gotchas
JavaScript Gotchas
 
The state of testing @ Microsoft
The state of testing @ MicrosoftThe state of testing @ Microsoft
The state of testing @ Microsoft
 
What is new in C# 6?
What is new in C# 6?What is new in C# 6?
What is new in C# 6?
 
A Developer Day 2014 - Durban
A Developer Day 2014 - Durban A Developer Day 2014 - Durban
A Developer Day 2014 - Durban
 
Agile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersAgile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM Rangers
 
Hour of code - Train the trainer
Hour of code - Train the trainerHour of code - Train the trainer
Hour of code - Train the trainer
 
Building services for apps on a shoestring budget
Building services for apps on a shoestring budgetBuilding services for apps on a shoestring budget
Building services for apps on a shoestring budget
 
3 things your app API is doing WRONG
3 things your app API is doing WRONG3 things your app API is doing WRONG
3 things your app API is doing WRONG
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
LightSwitch
LightSwitchLightSwitch
LightSwitch
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutes
 
Protection of Personal Information Bill (POPI)
Protection of Personal Information Bill (POPI)Protection of Personal Information Bill (POPI)
Protection of Personal Information Bill (POPI)
 
Open Source Licensing
Open Source LicensingOpen Source Licensing
Open Source Licensing
 

Último

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

RESTful design

  • 1. Understanding REST and designing for it RESTful Design
  • 2. Robert MacLean www.sadev.co.za @rmaclean BB&D ATC Introduction HTTP Basics URI’s Methods Status Codes Content Type Authentication URI Planning Patterns Style Accidental Services Examples Actions Guidelines Anti-Patterns Security Wrap Up About me Agenda Welcome
  • 3. REST Acronym? Representational State Transfer Source? Came about in 2000 doctoral dissertation of Roy Fielding
  • 4. What is it? ROA – Resource Orientated Architecture WOA – Web Orientated Architecture Thanks Gartner for another TLA  It is a style NOT API Interface Official Standard A drop in replacement for SOAP
  • 5. Benefits of REST Highly scalable Designed for HTTP Easy to consume & produce No complex request/response model. No complex XML contracts Easy to understand for you and machines URI + Method = Intent
  • 6. HTTP Basics REST builds on HTTP so you need to know HTTP HTTP is not HTML HTTP is stateless HTTP URI Header http://www.sadev.co.za Method GET Status Code 200 Content Type text/plain Body text
  • 7. URI Basics Hostname Scheme Query http://www.sadev.co.za/users/1/contact http://www.sadev.co.za?user=1&action=contact http://rob:pass@bbd.co.za:8044 https://bbd.co.za/index.html#about Query Hostname Scheme Userinfo Hostname Port Scheme Scheme Hostname Query Fragment
  • 9. Status Codes 1xx – Informational 2xx – Success 3xx – Redirection 4xx – Client Error 5xx – Server Error
  • 10. Status Codes Examples 100 = Continue 102 = Processing 200 = OK 201 = Created 204 = No Content 206 = Partial Content 301 = Moved Permanently 302 = Found (Moved Temp) 307 = Temp Redirect 400 = Bad Request 401 = Unauthorised 402 = Payment Required 403 = Forbidden 404 = Not Found 405 = Method Not Allowed 409 = Conflict 418 = I’m a teapot 450 = Blocked by Windows Parental Controls 500 = Internal Server Error 501 = Not Implemented
  • 11. Content Type Proper name: Internet Media Type Also known as MIME type Parts: Type, SubType, Optional Parameters x- prefix for nonstandard types or subtypes vnd. prefix for vendor specific subtypes Frowned upon by purists
  • 12. Content Type Examples text/plain – Plain text text/xml – XML text/html – HTML image/png – PNG image audio/basic – Wave audio audio/mpeg – MPEG audio (MP3) video/quicktime – Quicktime Video application/pdf – Adobe PDF document application/javascript – JavaScript application/vnd.ms-powerpoint – PowerPoint file application/x-rar-compressed – RAR file
  • 13. HTTP Authentication Basic Authentication Easy to do, but plain text. Easy to reverse engineer. Less of an issue when used with SSL. Digest Authentication Harder to do, still plain text. Hard (impossible?) to reverse engineer because of hashing. NTLM Authentication Hard to do, Windows specific. Hard (impossible?) to reverse engineer.
  • 14. Header Example Request HEAD /index.html HTTP/1.1 Host: www.example.com Response HTTP/1.1 200 OK Date: Mon, 23 May 2005 22:38:34 GMT Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT Etag: "3f80f-1b6-3e1cb03b" Accept-Ranges: bytes Content-Length: 438 Connection: close Content-Type: text/html; charset=UTF-8
  • 15. Lego Catalogue A simple system to store what LEGO’s a person owns. Want to Add bricks Set bricks status to be in use Remove bricks Get list of bricks Check if I have enough bricks Get picture of brick
  • 16. Lego Catalogue URI HTTP Valid REST Valid Intent good
  • 17. Lego Catalogue URI HTTP Valid REST Valid Intent good
  • 18. Lego Catalogue URI HTTP Valid REST Valid Intent good
  • 19. Lego Catalogue URI HTTP Valid REST Invalid Intent bad
  • 20. Lego Catalogue URI HTTP Valid REST Invalid Intent nightmare
  • 21. Real Life URI Example Resource: Photos Where: http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png) What: JPEG, GIF or PNG (defined in the URL) http://farm1.static.flickr.com/2/1418878_1e92283336_m.jpg
  • 22. REST Method Style “The big four”
  • 23. Accidental Services Accidental services do not use all methods Some URL’s offering all of them and others a limited set
  • 24. Methods Example http://bbddb01/northwind/users[firstname=“rob%”] + POST = Error + GET = Returns everyone who begins with rob + PUT = Error + DELETE = Deletes everyone who begins with rob http://bbddb01/northwind/users + we add some input data + POST = Creates a new user + GET = Returns everyone who meets criteria + PUT = Creates/Updates a user (based on data) + DELETE = Deletes everyone who meets criteria
  • 25. Methods Example http://bbddb01/northwind/users[firstname=“rob%”] + POST = Error + PUT = Error What would the error be? HTTP 400 would be best 405 or 500 could also be appropriate
  • 26. What about actions? GetStoreOpenTime(Location) GET http://lc/stores/{location}/times?state=open RejectDesign(Design) POST http://lc/rejections + form data PerformBrickCount(Design) POST http://lc/design/124/brickCount GET http://lc/design/124/brickCount/2
  • 27. Guidelines Design to be stateless Design for resources, not services Stock quote service vs. A way to work with stock resources Use cookies for self-contained state
  • 28. Guidelines Naming: Favour nouns over verbs GET /brick/2/delete DELETE /brick/2 Shorter nice URI’s preferred, not required Do not change URI’s Use 3xx redirection if needed
  • 29. Guidelines Give every resource an ID http://lc/brick/1 http://lc/project/planned/223 More URI’s the better
  • 30. Guidelines Support for multiple data types or representations For data use XML and/or JSON Postfixes to define type GET /brick/2/image.jpg GET /brick/2/image.png
  • 31. Guidelines Design with standards in mind – for example RSS & ATOM Create should return URI’s not resources Use the right HTTP methods for the right actions You are on HTTP – use the infrastructure. Proxy, Caching, Etag, Expires
  • 32. Guidelines Hyperlinks are good <project self=“http://lc/project/753”> <bricksUsed> <brick ref=“http://lc/brick/234” /> <brick ref=“http://lc/brick/286” /> <brick ref=“http://lc/brick/12” /> </bricksUsed> <coloursUsed> <colour name=“red” code=“ff0000” ref=“http://lc/brick/red”/> </coloursUsed> </project>
  • 33. Guidelines Offer paging <bricks self=“http://lc/bricks”> <link rel=“next” ref=“http://lc/bricks?page=20” /> … </bricks>
  • 34. Guidelines Offer collections of information <bricks> <brick ref=“http://lc/brick/1” /> <brick ref=“http://lc/brick/2” /> <brick ref=“http://lc/brick/3” /> </brick> <bricks> <brick ref=“http://lc/brick/1”> <colour>red</colour> </brick> <brick ref=“http://lc/brick/2”> <colour>red</colour> </brick> <brick ref=“http://lc/brick/3”> <colour>red</colour> </brick> </brick>
  • 35. Anti-Patterns Use one HTTP method – like GET for everything Often called GET or POST Tunnelling Pass everything in URI’s Assume this is a replacement for SOAP or WS*
  • 36. Security101 Are RESTful services secure? It’s a style, not a technology so that depends on how you implement it. Are you open to SQL injection attacks? When you look at http://bbddb01/northwind/users[firstname=“rob%”], you may think so but you shouldn’t be. Because: The parameter shouldn’t be SQL If it is SQL, why are you not filtering it? Remember the old rule: Do not trust user input URI’s are user input
  • 37. Security102 How can I do authentication? It’s built on HTTP, so everything you have for authentication in HTTP is available PLUS You could encode your authentication requirements into the input fields
  • 38. Good Examples WCF Data Services Previously called ADO.NET Data Services & Astoria NerdDinner.com Twitter.com MediaWiki Their action’s are frowned upon by purists
  • 39. Benefits of REST Highly scalable Designed for HTTP and stateless Easy to consume No complex request/response model. No complex XML contracts Easy to understand for you and machines URI + Method = Intent