how we rest
DESCRIPTION
Nathaniel Francis How we RESTTRANSCRIPT
![Page 1: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/1.jpg)
How We Rest
![Page 2: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/2.jpg)
Who Am I?@Francainath
![Page 3: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/3.jpg)
This is what I do:
(+ )
(REST)
![Page 4: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/4.jpg)
In the Beginning...
![Page 5: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/5.jpg)
Changing landscape
![Page 6: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/6.jpg)
Where we are today:
![Page 7: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/7.jpg)
PROBLEM:
How can we make our app work on allthese devices?
![Page 8: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/8.jpg)
solution #1: RESPONSIVE DESIGN
![Page 9: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/9.jpg)
solution #2: CUSTOM APPS Unique app for each environment
![Page 10: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/10.jpg)
This requires:
![Page 11: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/11.jpg)
Why REST?When compared to SOAP(Simple Object Access Protocol),REST is considered:
lighter weighteasier to use (for the most part)more flexible
![Page 12: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/12.jpg)
REST basicsApp architecture styleHTTP request-response model
hence web focused
REpresentational State TransferSupports HTTP methods:
GET, POST, PUT, DELETE, OPTIONS
Returns data in different formatsJSON, text, XML, etc.
![Page 13: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/13.jpg)
How We Rest5 key options
2 servers
3 frameworks
![Page 14: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/14.jpg)
Natively available in CF10+Uses separate servlet to run RESTRegister your RESTful servicesregister/manage RESTful aspects inCFC via metadata
![Page 15: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/15.jpg)
Setup/Configuration
RestInitApplication(rootPath[,serviceMapping[,options]])
(in application.cfc)
![Page 16: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/16.jpg)
Routing{domain}/rest/{serviceMapping}/{subResource}
Example:{domain}/rest/fantasyFootball/getQuarterback/{id}
![Page 17: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/17.jpg)
CFC code
SHOW TIME!!!(examples/CF10quarterback.cfcin github repo)
![Page 18: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/18.jpg)
Considerations"/rest" mapping
can change this by revising the context path for the RESTservlet in web.xml
Metadata in CFCsAdvocates: truly RESTCritics: verbose, confusing
![Page 19: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/19.jpg)
Natively available in Railo 4+Uses separate servlet to run RESTRegister your RESTful servicesregister/manage RESTful aspects inCFC via metadata
![Page 20: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/20.jpg)
Setup/Configuration
RestInitApplication(rootPath[,serviceMapping[,options]])
(in application.cfc)
![Page 21: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/21.jpg)
Routing{domain}/rest/{service}/{action}{domain}/rest/fantasyFootball/getRunningback/{id}
![Page 22: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/22.jpg)
CFC code
SHOW TIME!!!(examples/RailoRunningBack.cfcin github repo)
![Page 23: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/23.jpg)
Considerations"/rest" mapping
{domain}/rest/{service}/{action}
Metadata in CFCsAdvocates: truly RESTCritics: verbose, confusing
![Page 24: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/24.jpg)
REST focused frameworkDesign: make REST simple for CFworks as far back as CF8mostly conventions, someconfigurations necessary
![Page 25: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/25.jpg)
Setup/ConfigurationDownload from
Taffy.ioGithub (github.com/atuttle/Taffy)
Unzip into web root (preferred) or APIsubfolderApplication CFC attribute:extends="taffy.core.api"
![Page 26: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/26.jpg)
Routing
taffy:uri/taffy_uri attribute determinesroute connectionurl: {domain}/api/{players}
component extends="taffy.core.resource" taffy:uri="/players" { //cfc code}
![Page 27: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/27.jpg)
CFC code
SHOW TIME!!!(examples/taffyApplication.cfc andexamples/taffyWideReceiver.cfcin github repo)
![Page 28: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/28.jpg)
ConsiderationsSimple implementationDiverse: CF8+ (& corr. Railo)Well documentedTooling (Dashboard)configuration: known issues w/Tomcat
![Page 29: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/29.jpg)
Enterprise application frameworkconventions baseddiverse and extensibleREST as a module of your application
![Page 30: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/30.jpg)
Setup/Configuration
Preferred workflow: made directory for your appinstall ColdBox & preferred app skeletoninstall RELAX module
Takes roughly a minuteBest Practice: setup all your RESTCFCs in an API module
![Page 31: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/31.jpg)
Routing
SHOW TIME!!!(examples/ColdBoxModuleConfig.cfcin github repo)
![Page 32: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/32.jpg)
CFC code
SHOW TIME!!!(examples/ColdBoxTeam.cfcin github repo)
![Page 33: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/33.jpg)
Unique Considerations
Simple implementationVery extensible within Box familyRELAX as tester & documentationwell documentedRoutes fully customizeableVery little unique code in CFC
![Page 34: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/34.jpg)
Lightweight frameworkconventions basedvery simple, accessibleREST as an application option
![Page 35: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/35.jpg)
Setup/ConfigurationDownload from
fw1.riaforge.orggithub.com/framework-one/fw1coldbox.org/forgebox/view/fw1
setup app in application.cfcset routes/return data
![Page 36: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/36.jpg)
Routing
SHOW TIME!!!(examples/FW1Application.cfcin github repo)
![Page 37: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/37.jpg)
CFC code example
SHOW TIME!!!(examples/FW1kicker.cfcin github repo)
![Page 38: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/38.jpg)
Unique Considerations
Simple frameworksimple route setupVery little unique code in CFC
![Page 39: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/39.jpg)
RecommendationsEvery option worksnon-frameworks vs frameworksapplication architecture style &extensibility
what you wanna do "under the hood"
There is no universal "right option"
![Page 40: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/40.jpg)
REST is not afancy or a gimicTake security seriouslyMake your API robustget Creative!!!
![Page 41: How we rest](https://reader034.vdocument.in/reader034/viewer/2022052600/558505ced8b42ab8128b52b8/html5/thumbnails/41.jpg)
Thank Youhttps://github.com/Francainath/CFSummit-How-We-Rest