【问题标题】:Send list of IDs in Yesod route在 Yesod 路由中发送 ID 列表
【发布时间】:2018-01-16 20:41:36
【问题描述】:

我想在我的 Yesod 应用程序中有一个接受 ID 列表的路由

this page 看来,您可以在路线中使用 * 来接受列表,但是当我尝试它时

/api/user/#UserId      UserR  GET DELETE
/api/users/display/*UserIds  DisplayR GET

我收到了错误

Not in scope: type constructor or class ‘UserIds’
Perhaps you meant one of these:
  ‘UserId’ (imported from Import.NoFoundation),

如何接受路由中的 UserId 列表?

【问题讨论】:

  • IIRC,它必须是 UserId 而不是 UserIds
  • @Sibi 将其更改为 UserId 会出现错误“由于使用‘toPathMultiPiece’而导致 (PathMultiPiece UserId) 没有实例”
  • @Qwertie,听起来像是一个不同的问题;)

标签: haskell url-routing yesod


【解决方案1】:

路线需要

/api/users/display/*[UserId]  DisplayR GET

然后Handler需要取输入类型[UserId]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 2013-04-23
    • 2020-03-12
    • 1970-01-01
    • 2022-01-19
    • 2020-01-07
    相关资源
    最近更新 更多