CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Creating Fluent REST Client Interface
using Delphi REST Client
Components
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Speaker
• Cesar Romero• Delphi Developer for 20 years• Embarcadero MVP• Delphi Developer at Trier Sistemas, Brazil
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
AGENDA
•Delphi REST Client Components
• Json Data Objects
• Fluent Interface API
•Delphi REST Client Fluent Interface API
•Examples
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Delphi REST Client Components
• Introduced in Delphi and C++Builder XE5• Since XE8 it is based on System.Net.HttpClient - WinHTTP
• HTTPS without OpenSSL • no more libeay32.dll and ssleay32.dll deploy
• System.Threading based• REST Debugger
• Sources available • C:\Program Files\Embarcadero\Studio\18.0\source\data\rest\restdebugger
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Json Data Objects
• JSON parser • Supports
• Delphi 2009-10.1 Berlin• Platforms Win32, Win64 and ARM Android (MacOS and iOS may work)
• MIT License (MIT)• Author: Andreas Hausladen• https://github.com/ahausladen/JsonDataObjects
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Json Data Objects - Features
• Fast dual JSON parser for parsing UTF8 and UTF16 without conversion
• Automatic creation of arrays and objects• Easy access mode with implicit operators• Compact and formatted output modes• Variants support• Null can be auto-typecasted to a value type • Progress callback support for loading large JSON strings
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Fluent Interface API, what is it?
“...fluent interface is an implementation of an object oriented API that aims to provide more readable code.”
https://en.wikipedia.org/wiki/Fluent_interface
• normally implemented using a method cascading/method chaining• define through the return value of a called method• self-referential, where the new context is equivalent to the last context• terminated through the result of a void context
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Delphi REST Client Fluent Interface
• Interface Based• Uses Delphi REST Components • Uses Json Data Objects• Flexible and extensible• Very easy to use• MIT License (MIT)• https://bitbucket.org/cesarliws/delphi-fluent-rest-client
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Delphi REST Client Fluent Interface - Example
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Delphi REST Client Fluent Interface - Demos
• https://bitbucket.org/cesarliws/delphi-fluent-rest-client
CodeRage XI – Productivity, Platforms and Performance – embt.co/CodeRageXI
Thank [email protected]
Top Related