Use OnCommandGet to handle HTTP client requests. Use the following parameters:
void OnCommandGet(TsgcWSConnection Connection, TsgcWSHTTPRequestInfo RequestInfo,
ref TsgcWSHTTPResponseInfo ResponseInfo)
{
if (RequestInfo.Document == "/")
{
ResponseInfo.ContentText = "<html><head><title>Test Page</title></head><body></body></html>";
ResponseInfo.ContentType = "text/html";
ResponseInfo.ResponseNo = 200;
}
}
Use this event to customize the HTTP response, example: if you want that some endpoints are using an authorization scheme while others can be accessed without authorization, use the options parameter to allow or disable it. Find below an example when Authorization Basic is enabled but when a user requests the endpoint /public the authorization is not required.
public void OnBeforeCommand(TsgcWSConnection aConnection, TIdHTTPRequestInfo ARequestInfo, TIdHTTPResponseInfo AResponseInfo, ref TsgcHTTPCommandOptions aOptions)
{
if (ARequestInfo.Document == "/public")
aOptions = TsgcHTTPCommandOptions.hcoAuthorizedBasic;
}