[英]Configuration REST resources in mORMot
我想基于有关mORMot中REST路由的信息( http://synopse.info/forum/viewtopic.php?id=1833 )配置对REST资源的非常简单的访问。
我需要将url称为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
您可以只定义自己的路由类。
请参阅有关自定义路由的框架文档 。
覆盖两个对应的方法:
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;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.