0

我正在尝试使用参数过滤路由,但没有成功。我有 2 条路线:

/all
/:id

我正在使用typescript-rest进行动态加载,因此无法先添加所有路由。

Server.loadServices(this.appWebApi, 'app/resources/*.js', `${__dirname}`);

我有这两种方法:

@GET
@Path("all")
async all(@Context context: ServiceContext) {}

@GET
@Path(":id")
async findById(@Context context: ServiceContext, @PathParam("id") id: string) {}

但是当我使用/all. 我尝试使用^(?!all):id,但参数不起作用。

那么,如何过滤这两条路线呢?

4

1 回答 1

1

我找到了解决方案,问题与 typescript-rest 包有关。

这里建议的解决方案:

https://github.com/thiagobustamante/typescript-rest/issues/78#issuecomment-469232775

于 2020-02-26T18:01:49.417 回答