Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

How to make RESTful WebBroker using C++Builder

Author: Andrea L59044

 

I used FireDAC because I wanted to make a DB connection to MySQL DB.

Resource and suffix can be obtained with Request->PathInfo.

So decompose PathInfo into std::vector<UnicodeString> and put it in.

[crayon-672aa68b3ec62502535006/]

 

We made each resource as a member function.

[crayon-672aa68b3ec69611609312/]

 

And I set it on the map.

[crayon-672aa68b3ec6a052552444/]

 

Call from the main action function.

[crayon-672aa68b3ec6c570474916/]

Each resource implementation part.

It is the code below.

[crayon-672aa68b3ec6d476683201/]

http://localhost:8080/resource1/1

Accessing the above URL goes through the function of WebModule1WebActionResource1.

This function connects to DB using FireDAC.

 

http://localhost:8080/resource2/japan/America/2017

The above URL goes through the function of WebModule1WebActionResource2.

This is just a function to echo the item.

Two resource functions are returned by JSON.

 

[gist]

https://gist.github.com/mojeld/63592be8f6c371116f2145b37c2a54aa 

 

Exit mobile version