我想根据有关mORMot中REST路由的信息(http://synopse.info/forum/viewtopic.php?id=1833)配置对REST资源的非常简单的访问。
我需要将网址称为localhost/api/apservice/station/1
,但下面的代码仅用于调用localhost/api/apservice/station?stationid={stationid}
IAPIService = interface(IInvokable)
['{0F23D411-C3F0-451A-8580-AB5BE6E521E6}']
function Station(StationID: Integer; out Station: TSQLStation): TCQRSResult;
end;
TAPIService = class(TInterfacedObject, IAPIService)
private
fDbConnection : TSQLDBConnectionProperties;
public
constructor Create(const aProps: TSQLDBConnectionProperties ); overload;
public
function Station(StationID: Integer; out Station: TSQLStation): TCQRSResult;
end;
请告知我如何正确配置REST路由到我的资源?我需要以下示例:
return details for station=1
return all groups from station
答案 0 :(得分:0)
您可以定义自己的路由类。
有关自定义路由的信息,请参阅the framework documentation。
覆盖两个相应的方法:
TSQLRestServerURIContext = class
protected
...
/// retrieve interface-based SOA
procedure URIDecodeSOAByInterface; virtual; abstract;
/// direct launch of an interface-based service
procedure ExecuteSOAByInterface; virtual; abstract;
或定义method-based service,允许您定义的任何路由:
type
TMyRestServer = class(TSQLRestServerFullMemory)
(...)
published
procedure apservice(Ctxt: TSQLRestServerURIContext);
end;