uses
sgcHTTP;
var
HTTP2: TsgcHTTP2Client;
begin
HTTP2 := TsgcHTTP2Client.Create(nil);
HTTP2.Host := 'https://api.example.com';
HTTP2.OnHTTP2Response := HTTP2Response;
HTTP2.Active := True;
HTTP2.GetAsync('/v1/status');
end;
procedure TForm1.HTTP2Response(Sender: TObject;
const Connection: TsgcHTTP2ConnectionClient;
const Request: TsgcHTTP2RequestProperty;
const Response: TsgcHTTP2ResponseProperty);
begin
Memo1.Lines.Add(Response.DataString);
end;
uses
sgcHTTP;
var
GRPC: TsgcGRPCClient;
begin
GRPC := TsgcGRPCClient.Create(nil);
GRPC.Client.Host := 'https://grpc.example.com';
GRPC.OnGRPCResponse := GRPCResponse;
GRPC.CallAsync('example.OrderService', 'GetOrder', RequestBytes);
end;
procedure TForm1.GRPCResponse(Sender: TObject;
const aResponse: TsgcGRPCResponse);
begin
Memo1.Lines.Add(aResponse.DataString);
end;
uses
sgcHTTP_Server;
var
Server: TsgcHTTPServer;
begin
Server := TsgcHTTPServer.Create(nil);
Server.Port := 8080;
Server.DocumentRoot := 'C:\www';
Server.OnCommandGet := ServerCommandGet;
Server.Active := True;
end;
procedure TForm1.ServerCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo);
begin
if ARequestInfo.Document = '/api/status' then
begin
AResponseInfo.ContentType := 'application/json';
AResponseInfo.ContentText := '{"status":"ok"}';
end;
end;