在 TMS Sparkle 中从 URI 读取客户 ID 的优雅方式?

The elegant way to read Customer ID from URI in TMS Sparkle?

我正在使用 TMS Sparkle 开发休息 API,我想知道从这个请求中读取客户 {ID} 的优雅方式:

http://localhost/v1/customers/{ID}

我可以反向读取最后的字符,直到找到“/”字符,但没有看到 对我来说很优雅,还有另一种方法吗?

这个 {ID} 值是 RequestedPath 的一部分,但我想知道是否有一个 属性 保存这个值?

我已经阅读了 Examining the Request 文档教程的文档,但是没有提到如何从请求中读取互补值。

当您检查 Request 时,您可以通过 URI.Segments 属性 访问它的不同部分,如下所示:

procedure TMySparkleModule.ProcessRequest(const C: THttpServerContext);
var
  r: THttpServerRequest;
  str: string;
begin
  r:=C.Request;
  for str in r.Uri.Segments do
    ...
end;