with coldbox and rest. co-manager of iecfug flex, coldfusion, javascript developer a member of team...

14
Writing remote API's with ColdBox and REST

Upload: marcos-parrent

Post on 28-Mar-2015

219 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

Writing remote API'swith ColdBox and REST

Page 2: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

Kalen Gibbons

Co-Manager of IECFUG

Flex, ColdFusion, JavaScript Developer

A member of Team ColdBoxPresident of Sercossa Inc.

Page 3: With ColdBox and REST. 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

Page 4: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

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

Page 5: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

Using RESTRepresentational State Transfer

Page 6: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

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

Page 7: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

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

Page 8: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

Exposing DataIn new ways

Page 9: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

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

Page 10: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

Architectural Considerations

Creating a reusable model

Page 11: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

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

Page 12: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

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

Page 13: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

A Better Architecture

SQL Database SAP REST Service Other Sources

Business Services

Data Services

Page 14: With ColdBox and REST. Co-Manager of IECFUG Flex, ColdFusion, JavaScript Developer A member of Team ColdBoxPresident of Sercossa Inc

Thanks

[email protected]

@KalenGibbons