Idhttpserver (INDY10) Development Rest Middleware

Source: Internet
Author: User

Idhttpserver (INDY10) Development Rest Middleware

The browser queries the data URL sample by "Get": Http://127.0.0.1:7777/query?sql=select * from T1

/query means "query" command word

? The following is the SQL parameter

Service-Side code:

Procedure Tform1.idhttpserver1commandget (acontext:tidcontext; Arequestinfo:tidhttprequestinfo; Aresponseinfo:tidhttpresponseinfo);
Var
method, sql:string;
{$IFDEF ADO}
Dm:tfrmdmado;
{$ENDIF}
{$IFDEF ODAC}
Dm:tfrmdmodac;
{$ENDIF}
Begin
Method: = arequestinfo.document;  //gets the command word
If method = "then
Exit;
{$ifdef ADO}
CoInitialize (nil);
{$endif}
Try
If method = '/query ' then  //query data
begin
sql: = arequestinfo.params.values[' sql '];  //the SQL parameter
If sql = "then
Exit;
Aresponseinfo.responseno: = 0;
Aresponseinfo.contenttype: = ' text/html ';
{$IFDEF ADO}
DM: = tfrmdmado.create (nil);
{$ENDIF}
{$IFDEF Odac}
DM: = tfrmdmodac.create (nil);
{$ENDIF}
Try
Aresponseinfo.contenttext: = DM. Query (SQL);  //returns the data that the data engine queries to in JSON format
Aresponseinfo.writecontent;  //replies to the requester
finally
DM. Free;
End;
End;
except
on e:exception do
begin

End
End
{$ifdef ADO}
CoUninitialize;
{$ENDIF}
End

Idhttpserver (INDY10) Development Rest Middleware

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.