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. For example, if you want some endpoints to use an authorization scheme while others can be accessed without authorization, use the options parameter to allow or disable it. Below is an example where Authorization Basic is enabled, but when a user requests the endpoint /public, authorization is not required.
public void OnBeforeCommand(TsgcWSConnection aConnection, TIdHTTPRequestInfo ARequestInfo, TIdHTTPResponseInfo AResponseInfo, ref TsgcHTTPCommandOptions aOptions)
{
if (ARequestInfo.Document == "/public")
aOptions = TsgcHTTPCommandOptions.hcoAuthorizedBasic;
}