Multi Tenant and Swagger 2 - revisited

The thread was closed before I could add the code I used to make this work:

procedure TServerContainer.ApiServerModuleCreate(Sender: TObject; Module:
    TXDataServerModule);
begin
  Module.OnGetAbsoluteUrl :=
    procedure(const Schema, Authority, Path, RelativeUrl: string; var Url: string)
    var Tenant: ITenant;
        UrlStart,UrlEnd: String;
        lPos: Integer;
    begin
      Tenant := THttpServerContext.Current.Item<ITenant>;
      if Tenant <> nil then
      begin
        lPos := Url.IndexOf(ApiServerTenant.BasePath);
        UrlStart := Url.SubString(0, lPos + ApiServerTenant.BasePath.Length + 1);
        UrlEnd := Url.Substring(lPos + ApiServerTenant.BasePath.Length);
        Url := UrlStart + Tenant.TenantId + UrlEnd;
      end;
    end;
end;
1 Like

Ref: Multi tenant and Swagger 2 - #6 by wlandgraf

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.