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

Post on 28-Mar-2015

217 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

Thanks

Kalen@Sercossa.com

@KalenGibbons

top related