TsgcWebSocketServer_HTTPAPIEvents › OnBeforeBinding

OnBeforeBinding Event

Fires before the server binds to the configured URL, so the list of bindings can be inspected or customized.

Syntax

property OnBeforeBinding: TsgcWSHTTPAPIBeforeBinding;
// TsgcWSHTTPAPIBeforeBinding = procedure(Sender: TObject; const Bindings: TStrings) of object

Default Value

Remarks

OnBeforeBinding is raised after the component has collected the URLs that will be registered with HTTP.SYS (from the Host/Port pair and from any entries added through Bindings.NewBinding) and before those URL prefixes are actually reserved. The Bindings parameter is the TStrings list of URL prefixes (for example "http://127.0.0.1:80/" or "https://+:443/"); clear, add or rewrite entries in this list to change which endpoints the kernel driver will listen on. This is the right place to inject per-environment bindings at runtime without touching the designer properties.

Example


procedure OnBeforeBinding(Sender: TObject; const Bindings: TStrings);
begin
  Bindings.Clear;
  Bindings.Add('http://127.0.0.1:80/');
  Bindings.Add('http://+:8080/api/');
end;

Back to Events