unigui作中間件使用
可返回string或者tstream數據。
如果返回JSON字符,則UNIGUI就是REST 中間件。
procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean);
var
cmd, sql: string;
begin
cmd := ARequestInfo.URI;
if Pos('query', cmd) > 0 then
begin
sql := ARequestInfo.Params.Values['sql'];
if sql <> '' then
begin
Handled := true;
AResponseInfo.CharSet := 'UTF-8';
AResponseInfo.ContentType := 'UTF-8';
AResponseInfo.ContentText := 'unigui中間件';
end;
end;
end;
瀏覽器打開 URL:http://127.0.0.1:9999/query/?sql=select * from tgoods