SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
www.intothebox.org
4.0 rebuilt from the ground-up to make building

RESTful services a breeze
RESTful-ly Goodness
Simplify common API Tasks
• Coldbox Routing

• Request Context:


renderData();
getHTTPHeader();
getHTTPMethod();
• Coldbox Proxy
• Modularity
• Interceptors
Powerful Routing Configuration
// API Routing
var defaultAPIActions = {
"GET":"index",
"POST":"add",
"PUT":"onInvalidHTTPMethod",
"PATCH":"onInvalidHTTPMethod",
"DELETE":"onInvalidHTTPMethod"
};
var defaultEntityActions = {
"GET":"get",
"PUT":"update",
"PATCH":"update",
"DELETE":"delete"
};
//Users API Routes

addRoute(
pattern='/api/v1/users/:id',
handler='api.v1.Users',
action=defaultEntityActions
);
addRoute(
pattern='/api/v1/users',
handler='api.v1.Users',
action=defaultAPIActions
);
Built-In Methods to Minimize Duplication of Effort
function preHandler(event,action,eventArguments,rc,prc){
rc.format="JSON";
//404 default
rc.statusCode=STATUS.NOT_FOUND;
rc.data = {};
event.noLayout();
//handle any content payloads
if(
len(getHttpRequestData().content)
and
isJson(getHttpRequestData().content)
) structAppend(rc, deserializeJson(getHttpRequestData().content),true);


//set our access control allow origin header for cross-domain requests
header name="Access-Control-Allow-Origin" value="*";
//process our login tokens
processAuthenticationTokens(argumentCollection=arguments);
prc.currentUser = SessionService.getCurrentUser();
}
preHandler()
Built-In Methods to Minimize Duplication of Effort
function postHandler(event,action,eventArguments,rc,prc){
event.renderData(
type=rc.format,
data=rc.data,
statusCode=rc.statusCode,
statusMessage=event.getValue(“statusMessage”, “Success”)
);
}
postHandler()
Pre-configured REST App Template
mkdir myapi --cd
coldbox create app skeleton=rest name=MyService --installColdBox

server start --rewritesEnable
A powerful, R.A.D. framework
for building REST APIs
API Documentation
• Helps to define coding conventions

• Allows API evolution to maintain consistency and
standards

• Decreases onboarding time and increases
adoption for API consumers

• Provides flexibility in development sprint planning
by allowing members, owners, and stakeholders
to visualize the product and ensure needs are met
RELAX
A business case for developers:
Next Generation
RELAX
• Open and transferrable documentation using OpenAPI
(fka Swagger)

• Maintain backward compatibility for RelaxDSL (for a
time)

• Minimize the need for duplication of effort

• Streamline the drill-down process to the response level

• Make documentation authoring and revisions pain-free
Next Generation
RELAX
Integrated
Responsive
Descriptive
Exportable
Extendable
Navigable
Next Generation
RELAX
Drill down quickly
to paths, methods,
schemas and
samples

References and
internal document
links

Extend OpenAPI
schema to
(near)infinite
Next Generation
RELAX
Fully recursive to
allow for automation
and uniform
consumption of
documentation
resources
Long-term…
RELAX
Evaluate and evolve
through innovation
and by incorporating
the best features of
API Tools, integrating
them into a single
workflow
A Tour
RELAX
API Development
Lessons Learned:
• Maintain consistency in responses to minimize conditionals
in consumption

• Implement your paging and throttling strategies *NOW*!

• Standardize error handling

• Less is *more* (Massive data dumps kill your API)

• Marshall deeply nested arrays into hashmap representations,
whenever possible. Recursion kills.
API Development
Lessons Learned:
GET
POST
PUT
PATCH
DELETE
HEAD
OPTIONS
http://www.restapitutorial.com/lessons/httpmethods.html
API Development
Lessons Learned:
http://www.restapitutorial.com/httpstatuscodes.html
API Development
Lessons Learned:
200 - “You wanted it... Here you go, buddy:”
201 - “I've created something new for you!”
202 - “Your request is accepted, heres a URL so you
can check the status:”
203 - “Here's a record, but we haven't confirmed
persistence”
204 - “I deleted what you told me. Now it's nothing,
so... Here's nothing!:”
205 - “A record has been updated while you were
slacking off. Re-request the data and refresh your
view.”
206 - “There are, like, a gazillion rows, man. Here's 25
of them so I don't break
Q&A
RELAX
REST
&
Next Session Begins @ 11:15AM

Más contenido relacionado

La actualidad más candente

Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11
ColdFusionConference
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
Dima Maleev
 

La actualidad más candente (20)

Securing applications
Securing applicationsSecuring applications
Securing applications
 
Excellent rest using asp.net web api
Excellent rest using asp.net web apiExcellent rest using asp.net web api
Excellent rest using asp.net web api
 
Web Server-Side Programming Techniques
Web Server-Side Programming TechniquesWeb Server-Side Programming Techniques
Web Server-Side Programming Techniques
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11Developing html5 mobile applications using cold fusion 11
Developing html5 mobile applications using cold fusion 11
 
Websphere interview Questions
Websphere interview QuestionsWebsphere interview Questions
Websphere interview Questions
 
A Bit of REST
A Bit of RESTA Bit of REST
A Bit of REST
 
Web API or WCF - An Architectural Comparison
Web API or WCF - An Architectural ComparisonWeb API or WCF - An Architectural Comparison
Web API or WCF - An Architectural Comparison
 
How we rest
How we restHow we rest
How we rest
 
Web servers
Web serversWeb servers
Web servers
 
Web api
Web apiWeb api
Web api
 
Web Servers (ppt)
Web Servers (ppt)Web Servers (ppt)
Web Servers (ppt)
 
ColdFusion Fw1 (FrameWork1) introduction
ColdFusion Fw1 (FrameWork1) introductionColdFusion Fw1 (FrameWork1) introduction
ColdFusion Fw1 (FrameWork1) introduction
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
2009 - Microsoft IIS Vs. Apache - Who Serves More - A Study
2009 - Microsoft IIS Vs. Apache - Who Serves More - A Study2009 - Microsoft IIS Vs. Apache - Who Serves More - A Study
2009 - Microsoft IIS Vs. Apache - Who Serves More - A Study
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
 
Alfresco Architecture
Alfresco ArchitectureAlfresco Architecture
Alfresco Architecture
 
Enjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web APIEnjoying the Move from WCF to the Web API
Enjoying the Move from WCF to the Web API
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical Approach
 
New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0New Features Of ASP.Net 4 0
New Features Of ASP.Net 4 0
 

Destacado

Sitcom quiz!
Sitcom quiz!Sitcom quiz!
Sitcom quiz!
Burtoni
 

Destacado (20)

Digipak
DigipakDigipak
Digipak
 
ITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLI
 
Fc, cp, dps
Fc, cp, dpsFc, cp, dps
Fc, cp, dps
 
ORM Pink Unicorns
ORM Pink UnicornsORM Pink Unicorns
ORM Pink Unicorns
 
Pro forma
Pro formaPro forma
Pro forma
 
Office administrative assistant
Office administrative assistantOffice administrative assistant
Office administrative assistant
 
CBDW2014 - This is ColdBox 4
CBDW2014 - This is ColdBox 4CBDW2014 - This is ColdBox 4
CBDW2014 - This is ColdBox 4
 
Horror
HorrorHorror
Horror
 
Sitcom quiz!
Sitcom quiz!Sitcom quiz!
Sitcom quiz!
 
ITB2016 - ContentBox Modular CMS
ITB2016 - ContentBox Modular CMSITB2016 - ContentBox Modular CMS
ITB2016 - ContentBox Modular CMS
 
Welcome
WelcomeWelcome
Welcome
 
Gentech
GentechGentech
Gentech
 
Физика и техника.
Физика и техника.Физика и техника.
Физика и техника.
 
Ancillary task
Ancillary taskAncillary task
Ancillary task
 
Narrative Structure
Narrative StructureNarrative Structure
Narrative Structure
 
How to save a life
How to save a lifeHow to save a life
How to save a life
 
Creating a Drop Shadow
Creating a Drop ShadowCreating a Drop Shadow
Creating a Drop Shadow
 
Story book
Story bookStory book
Story book
 
Center for Education on Social Responsibility (CESR) Introduction
Center for Education on Social Responsibility (CESR) IntroductionCenter for Education on Social Responsibility (CESR) Introduction
Center for Education on Social Responsibility (CESR) Introduction
 
Album artwork
Album artworkAlbum artwork
Album artwork
 

Similar a ITB2016 - Building ColdFusion RESTFul Services

Innovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open InterfacesInnovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open Interfaces
Steve Speicher
 

Similar a ITB2016 - Building ColdFusion RESTFul Services (20)

JOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - RESTful API Concepts and Best PracticesJOSA TechTalks - RESTful API Concepts and Best Practices
JOSA TechTalks - RESTful API Concepts and Best Practices
 
RESTful web APIs (build, document, manage)
RESTful web APIs (build, document, manage)RESTful web APIs (build, document, manage)
RESTful web APIs (build, document, manage)
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5
 
Andrei shakirin rest_cxf
Andrei shakirin rest_cxfAndrei shakirin rest_cxf
Andrei shakirin rest_cxf
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in Codeigniter
 
SharePoint 2013 REST APIs
SharePoint 2013 REST APIsSharePoint 2013 REST APIs
SharePoint 2013 REST APIs
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in Magento
 
Apigility-powered API's on IBM i
Apigility-powered API's on IBM iApigility-powered API's on IBM i
Apigility-powered API's on IBM i
 
REST in Peace
REST in PeaceREST in Peace
REST in Peace
 
Getting Started with API Management
Getting Started with API ManagementGetting Started with API Management
Getting Started with API Management
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?Webinar: What's new in CDAP 3.5?
Webinar: What's new in CDAP 3.5?
 
Rest ful tools for lazy experts
Rest ful tools for lazy expertsRest ful tools for lazy experts
Rest ful tools for lazy experts
 
RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
 
Java colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rsJava colombo-deep-dive-into-jax-rs
Java colombo-deep-dive-into-jax-rs
 
Innovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open InterfacesInnovate2014 Better Integrations Through Open Interfaces
Innovate2014 Better Integrations Through Open Interfaces
 
Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...
 Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data... Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...
Big Data Web applications for Interactive Hadoop by ENRICO BERTI at Big Data...
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHP
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
 

Más de Ortus Solutions, Corp

Más de Ortus Solutions, Corp (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Ortus Government.pdf
Ortus Government.pdfOrtus Government.pdf
Ortus Government.pdf
 
Luis Majano The Battlefield ORM
Luis Majano The Battlefield ORMLuis Majano The Battlefield ORM
Luis Majano The Battlefield ORM
 
Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI
 
Secure your Secrets and Settings in ColdFusion
Secure your Secrets and Settings in ColdFusionSecure your Secrets and Settings in ColdFusion
Secure your Secrets and Settings in ColdFusion
 
Daniel Garcia ContentBox: CFSummit 2023
Daniel Garcia ContentBox: CFSummit 2023Daniel Garcia ContentBox: CFSummit 2023
Daniel Garcia ContentBox: CFSummit 2023
 
ITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdf
ITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdfITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdf
ITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdf
 
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdfITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
 
ITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdf
ITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdfITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdf
ITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdf
 
ITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdf
ITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdfITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdf
ITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdf
 
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdfITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
 
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdfITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
 
ITB_2023_CBWire_v3_Grant_Copley.pdf
ITB_2023_CBWire_v3_Grant_Copley.pdfITB_2023_CBWire_v3_Grant_Copley.pdf
ITB_2023_CBWire_v3_Grant_Copley.pdf
 
ITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdf
ITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdfITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdf
ITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdf
 
ITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdf
ITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdfITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdf
ITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdf
 
ITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdf
ITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdfITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdf
ITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdf
 
ITB_2023_Chatgpt_Box_Scott_Steinbeck.pdf
ITB_2023_Chatgpt_Box_Scott_Steinbeck.pdfITB_2023_Chatgpt_Box_Scott_Steinbeck.pdf
ITB_2023_Chatgpt_Box_Scott_Steinbeck.pdf
 
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
 
ITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdf
ITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdfITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdf
ITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdf
 
ITB2023 Developing for Performance - Denard Springle.pdf
ITB2023 Developing for Performance - Denard Springle.pdfITB2023 Developing for Performance - Denard Springle.pdf
ITB2023 Developing for Performance - Denard Springle.pdf
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

ITB2016 - Building ColdFusion RESTFul Services

  • 2. 4.0 rebuilt from the ground-up to make building
 RESTful services a breeze
  • 3. RESTful-ly Goodness Simplify common API Tasks • Coldbox Routing
 • Request Context: 
 renderData(); getHTTPHeader(); getHTTPMethod(); • Coldbox Proxy • Modularity • Interceptors
  • 4. Powerful Routing Configuration // API Routing var defaultAPIActions = { "GET":"index", "POST":"add", "PUT":"onInvalidHTTPMethod", "PATCH":"onInvalidHTTPMethod", "DELETE":"onInvalidHTTPMethod" }; var defaultEntityActions = { "GET":"get", "PUT":"update", "PATCH":"update", "DELETE":"delete" }; //Users API Routes
 addRoute( pattern='/api/v1/users/:id', handler='api.v1.Users', action=defaultEntityActions ); addRoute( pattern='/api/v1/users', handler='api.v1.Users', action=defaultAPIActions );
  • 5. Built-In Methods to Minimize Duplication of Effort function preHandler(event,action,eventArguments,rc,prc){ rc.format="JSON"; //404 default rc.statusCode=STATUS.NOT_FOUND; rc.data = {}; event.noLayout(); //handle any content payloads if( len(getHttpRequestData().content) and isJson(getHttpRequestData().content) ) structAppend(rc, deserializeJson(getHttpRequestData().content),true); 
 //set our access control allow origin header for cross-domain requests header name="Access-Control-Allow-Origin" value="*"; //process our login tokens processAuthenticationTokens(argumentCollection=arguments); prc.currentUser = SessionService.getCurrentUser(); } preHandler()
  • 6. Built-In Methods to Minimize Duplication of Effort function postHandler(event,action,eventArguments,rc,prc){ event.renderData( type=rc.format, data=rc.data, statusCode=rc.statusCode, statusMessage=event.getValue(“statusMessage”, “Success”) ); } postHandler()
  • 7. Pre-configured REST App Template mkdir myapi --cd coldbox create app skeleton=rest name=MyService --installColdBox
 server start --rewritesEnable
  • 8. A powerful, R.A.D. framework for building REST APIs
  • 9.
  • 10. API Documentation • Helps to define coding conventions
 • Allows API evolution to maintain consistency and standards
 • Decreases onboarding time and increases adoption for API consumers
 • Provides flexibility in development sprint planning by allowing members, owners, and stakeholders to visualize the product and ensure needs are met RELAX A business case for developers:
  • 11. Next Generation RELAX • Open and transferrable documentation using OpenAPI (fka Swagger)
 • Maintain backward compatibility for RelaxDSL (for a time)
 • Minimize the need for duplication of effort
 • Streamline the drill-down process to the response level
 • Make documentation authoring and revisions pain-free
  • 13. Next Generation RELAX Drill down quickly to paths, methods, schemas and samples
 References and internal document links
 Extend OpenAPI schema to (near)infinite
  • 14. Next Generation RELAX Fully recursive to allow for automation and uniform consumption of documentation resources
  • 15. Long-term… RELAX Evaluate and evolve through innovation and by incorporating the best features of API Tools, integrating them into a single workflow
  • 17. API Development Lessons Learned: • Maintain consistency in responses to minimize conditionals in consumption
 • Implement your paging and throttling strategies *NOW*!
 • Standardize error handling
 • Less is *more* (Massive data dumps kill your API)
 • Marshall deeply nested arrays into hashmap representations, whenever possible. Recursion kills.
  • 20. API Development Lessons Learned: 200 - “You wanted it... Here you go, buddy:” 201 - “I've created something new for you!” 202 - “Your request is accepted, heres a URL so you can check the status:” 203 - “Here's a record, but we haven't confirmed persistence” 204 - “I deleted what you told me. Now it's nothing, so... Here's nothing!:” 205 - “A record has been updated while you were slacking off. Re-request the data and refresh your view.” 206 - “There are, like, a gazillion rows, man. Here's 25 of them so I don't break
  • 22. Next Session Begins @ 11:15AM