Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How we rest

870 views

Published on

Nathaniel Francis How we REST

Published in: Software
  • Be the first to comment

  • Be the first to like this

How we rest

  1. 1. How We Rest
  2. 2. Who Am I? @Francainath
  3. 3. This is what I do: (+ ) (REST)
  4. 4. In the Beginning...
  5. 5. Changing landscape
  6. 6. Where we are today:
  7. 7. PROBLEM: How can we make our app work on all these devices?
  8. 8. solution #1: RESPONSIVE DESIGN
  9. 9. solution #2: CUSTOM APPS Unique app for each environment
  10. 10. This requires:
  11. 11. Why REST? When compared to SOAP (Simple Object Access Protocol), REST is considered: lighter weight easier to use (for the most part) more flexible
  12. 12. REST basics App architecture style HTTP request-response model hence web focused REpresentational State Transfer Supports HTTP methods: GET, POST, PUT, DELETE, OPTIONS Returns data in different formats JSON, text, XML, etc.
  13. 13. How We Rest 5 key options 2 servers 3 frameworks
  14. 14. Natively available in CF10+ Uses separate servlet to run REST Register your RESTful services register/manage RESTful aspects in CFC via metadata
  15. 15. Setup/Configuration RestInitApplication(rootPath[,serviceMapping[,options]]) (in application.cfc)
  16. 16. Routing {domain}/rest/{serviceMapping}/{subResource} Example: {domain}/rest/fantasyFootball/getQuarterback/{id}
  17. 17. CFC code SHOW TIME!!! (examples/CF10quarterback.cfc in github repo)
  18. 18. Considerations "/rest" mapping can change this by revising the context path for the REST servlet in web.xml Metadata in CFCs Advocates: truly REST Critics: verbose, confusing
  19. 19. Natively available in Railo 4+ Uses separate servlet to run REST Register your RESTful services register/manage RESTful aspects in CFC via metadata
  20. 20. Setup/Configuration RestInitApplication(rootPath[,serviceMapping[,options]]) (in application.cfc)
  21. 21. Routing {domain}/rest/{service}/{action} {domain}/rest/fantasyFootball/getRunningback/{id}
  22. 22. CFC code SHOW TIME!!! (examples/RailoRunningBack.cfc in github repo)
  23. 23. Considerations "/rest" mapping {domain}/rest/{service}/{action} Metadata in CFCs Advocates: truly REST Critics: verbose, confusing
  24. 24. REST focused framework Design: make REST simple for CF works as far back as CF8 mostly conventions, some configurations necessary
  25. 25. Setup/Configuration Download from Taffy.io Github (github.com/atuttle/Taffy) Unzip into web root (preferred) or API subfolder Application CFC attribute: extends="taffy.core.api"
  26. 26. Routing component extends="taffy.core.resource" taffy:uri="/players" { //cfc code } taffy:uri/taffy_uri attribute determines route connection url: {domain}/api/{players}
  27. 27. CFC code SHOW TIME!!! (examples/taffyApplication.cfc and examples/taffyWideReceiver.cfc in github repo)
  28. 28. Considerations Simple implementation Diverse: CF8+ (& corr. Railo) Well documented Tooling (Dashboard) configuration: known issues w/Tomcat
  29. 29. Enterprise application framework conventions based diverse and extensible REST as a module of your application
  30. 30. Setup/Configuration Preferred workflow: made directory for your app install ColdBox & preferred app skeleton install RELAX module Takes roughly a minute Best Practice: setup all your REST CFCs in an API module
  31. 31. Routing SHOW TIME!!! (examples/ColdBoxModuleConfig.cfc in github repo)
  32. 32. CFC code SHOW TIME!!! (examples/ColdBoxTeam.cfc in github repo)
  33. 33. Unique Considerations Simple implementation Very extensible within Box family RELAX as tester & documentation well documented Routes fully customizeable Very little unique code in CFC
  34. 34. Lightweight framework conventions based very simple, accessible REST as an application option
  35. 35. Setup/Configuration Download from fw1.riaforge.org github.com/framework-one/fw1 coldbox.org/forgebox/view/fw1 setup app in application.cfc set routes/return data
  36. 36. Routing SHOW TIME!!! (examples/FW1Application.cfc in github repo)
  37. 37. CFC code example SHOW TIME!!! (examples/FW1kicker.cfc in github repo)
  38. 38. Unique Considerations Simple framework simple route setup Very little unique code in CFC
  39. 39. Recommendations Every option works non-frameworks vs frameworks application architecture style & extensibility what you wanna do "under the hood" There is no universal "right option"
  40. 40. REST is not afancy or a gimic Take security seriously Make your API robust get Creative!!!
  41. 41. Thank You https://github.com/Francainath/CFSummit- How-We-Rest

×