Jump to content

combining UniGui with REST-WebService


bitschieber

Recommended Posts

Hi all!

We are trying to combine the TUniServerModule with our
REST-WebService-component (customized Indy HttpServer).

In this case, is there any posibility to get an event like Indy's
Http-Server 'OnCommandGet' or 'OnCommandOther' to handle individual
http-reqeusts? We want to use only one port in the whole application to
avoid cross-domain problems.

Thanks a lot

 

  • Upvote 1
Link to comment
Share on other sites

We are currently using self-programmed components which communicate via web services rest. We want to include these components in our Unigui application. That is why we need a service of Unigui and REST Web services can operate. 

A proposed solution would be to declare public 

  'OnCommandGet' and 'OnCommandOther'.
  • Upvote 1
Link to comment
Share on other sites

Hi!

 

Thanks a lot for implementing the new OnHttpCommand-Event, it was really helpful!

 

But we noticed that not all common http-methods are supported in this event, for example DELETE, PUT or OPTIONS. Only GET and POST are still working. To implement an entire REST-ful webservice, we do need the methods: GET, PUT, POST, DELETE and OPTIONS.

 

Is there any way to get the "OnHttpCommand"-event triggered on those HTTP-standarded methods?

 

Thanks a lot!
Link to comment
Share on other sites

  • Administrators

It will be fixed in next version..

 

Workaround:

unit ServerModule;
interface
uses
  SysUtils, uniGUIServer, uniGUIMainModule, uniGUIApplication,  

// add
  uIdContext,
  uIdCustomHTTPServer,
  ExtHTTPServer;
// add

type
  TUniServerModule = class(TUniGUIServerModule)
    procedure UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean);
  private
    { Private declarations }
  protected
    procedure FirstInit; override;
  public
    { Public declarations }  
// add
    procedure CommandOther(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
    procedure AfterConstruction; override;
// add
  end;

function UniServerModule: TUniServerModule;

implementation

{$R *.dfm}
uses
  UniGUIVars;

function UniServerModule: TUniServerModule;
begin
  Result:=TUniServerModule(UniGUIServerInstance);
end;

procedure TUniServerModule.FirstInit;
begin
  InitServerModule(Self);
end;

// add
procedure TUniServerModule.AfterConstruction;
begin
  inherited;
  ExtApplication.Server.OnCommandOther := CommandOther;
end;

procedure TUniServerModule.CommandOther(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
//
end;
// add

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;  var Handled: Boolean);
begin
//
end;

initialization
  RegisterServerModuleClass(TUniServerModule);
end.
Link to comment
Share on other sites

  • 3 years later...
×
×
  • Create New...