RTC Forums
November 24, 2024, 03:42:23 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: REST server example  (Read 4793 times)
ClementDoss
RTC License
***
Posts: 36


« on: November 14, 2015, 09:23:21 PM »

Hi,

Do you have an example (or guidelines) to build a REST server using RTC?
I would like to build a server given the client might not be using RTC.

TIA,
Clément
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: November 16, 2015, 08:49:09 AM »

There are no REST-specific examples in the RTC SDK, but ... if you know how to use the RTC SDK to build a Server (which is already covered in Quick Start examples) and you understand the protocol, you should be able to do it with the RTC SDK. You have full access to all the data you get with Client requests and you have full control when preparing your responses, so it's all about processing that request data to prepare the appropriate response. If you are new to REST and want to learn the protocol, you can start by googling "REST guidelines".

Best Regards,
Danijel Tkalcec
Logged
ClementDoss
RTC License
***
Posts: 36


« Reply #2 on: November 17, 2015, 04:59:49 PM »

Hi Danijel,

I'm familiar with the REST protocol. I want to be sure I'm not reinventing the wheel  Wink

For example, rtcserver will receive a GET like: http://www.acme.com/product/0

I don't know how to accept this request. How should I inform rtcServer that http://www.acme.com/product is the actual link, and that 0 is the ID the user requested.
The rtcServer will receive actions ( GET, POST, DELETE and PUT) but the complement with parameters is confusing me.

Another example:  http://www.acme.com/productlist/rtcserver/20151117/dan
The route is http://www.acme.com/productlist , all the rest are parameters.


TIA,
Clément
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: November 18, 2015, 09:59:01 AM »

Implement the OnCheckRequest event on the TRtcDataRequest component to evaluate the Request object, which contains all the request headers (Method, FileName, FilePath, Query, Params, ...) and Accept the request if you want to process it with the TRtcDataProvider component, then implement the OnDataReceived event to process the request body (if any) and send out a response. If you don't know how to work with the TRtcHttpServer and TRtcDataProvider components to accept and process requests, start by going through Quick Start examples (available in the FAQ and in the QuickStart folder).

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 17 queries.