我希望根据有关mORMot中REST路由的信息(MORMot)配置对REST资源的非常简单的访问。
我需要以localhost/api/apservice/station/1的形式调用url,但是下面的代码只适用于作为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=1return all groups from station发布于 2016-09-05 19:23:09
您可以定义自己的路由类。
关于自定义路由,请参见框架文件。
重写两个相应的方法:
TSQLRestServerURIContext = class
protected
...
/// retrieve interface-based SOA
procedure URIDecodeSOAByInterface; virtual; abstract;
/// direct launch of an interface-based service
procedure ExecuteSOAByInterface; virtual; abstract;或者定义一个基于方法的服务,它允许您可以定义的任何路由:
type
TMyRestServer = class(TSQLRestServerFullMemory)
(...)
published
procedure apservice(Ctxt: TSQLRestServerURIContext);
end;https://stackoverflow.com/questions/32637805
复制相似问题