With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team...
-
Upload
marcos-parrent -
Category
Documents
-
view
217 -
download
3
Transcript of With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team...
Writing remote API'swith ColdBox and REST
Kalen Gibbons
Co-Manager of IECFUG
Flex, ColdFusion, JavaScript Developer
A member of Team ColdBoxPresident of Sercossa Inc.
Value of the ModelData is the most important part of your application
Exposing your modelThe web is evolving
Heavier front-end applicationsMobileFrequent integrations
Requires more optionsStandard page view (PV) modelREST (JSON, XML, etc)AMF (raw data for Flash/Flex)Many others
Using RESTRepresentational State Transfer
Creating RoutesConfig/routes.cfm
addRoute(pattern="/customers", handler="remote.customers", action={GET="getAllCustomers"});
HTTP VerbsGET, POST, PUT, DELETE
Can use existing handlersBut typically need to customize results
Creating HandlersHandlers know who to talk to
Use a base handler to make life easyPreHandler : prepares dataPostHandler : marshals data
Exception Handling is requiredErrors must be returned in the correct formatOnError : Handles exceptions and marshals data
Exposing DataIn new ways
Example: AMF API’sAction Message Format for Flash/Flex
Binary format for serializing CF objects to ActionScriptActs like a plain CFC method invocation
Uses ColdBox Proxy to enable the full ColdBox Request Life Cycles Allowing interceptors, AOP, etc. to work normally
Can extend remote functionality to suite needs
Architectural Considerations
Creating a reusable model
What are Handler for?Handler are Controllers
They know what data is requiredThey know who to talk to
Handlers are NOT for:Business logicData processing
Mixing logic in your handles creates duplication
ExampleHandlers with logic Leveraging services
Security
Logging
Error Handling
Data manipulation
Security
Logging
Error Handling
Data manipulation
Security
Logging
Error Handling
Data manipulation Security
Logging
Error Handling
Data manipulation
A Better Architecture
SQL Database SAP REST Service Other Sources
Business Services
Data Services