【问题标题】:How to add more than one parameters in ChicagoBoss route如何在 ChicagoBoss 路由中添加多个参数
【发布时间】:2017-04-20 02:03:24
【问题描述】:

我正在尝试使以下链接正常工作: http://localhost:8001/name/jason/grey

和路线定义:

{"/name/([a-zA-Z]+)/([a-zA-Z]+)", [{controller, "stuff"}, {action, "getStudentNames"}, [{firstname, '$1'}, {lastname, '$2'}]]}.

然后在我的控制器中

getStudentNames('GET', [FirstName, LastName])->
  {output, "ok"}.

我收到以下错误消息

CRASH REPORT Process <0.313.0> with 0 neighbours exited with reason: no function clause matching boss_router_controller:'-index_and_extract_params/1-fun-0-'([{firstname,'$1'},{lastname,'$2'}], []) line 258 in gen_server:terminate/7 line 812

似乎我的路线定义不正确,有什么帮助吗?

【问题讨论】:

    标签: erlang chicagoboss


    【解决方案1】:

    终于搞定了,万一有人遇到同样的问题。不要在路由定义中使用元组列表来定义参数,而是使用以逗号分隔的元组,例如

    {"/name/([a-zA-Z]+)/([a-zA-Z]+)", [{controller, "stuff"}, {action, "getStudentNames"}, {firstname, '$1'}, {lastname, '$2'}]}.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-24
      • 2012-05-10
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      • 2023-01-09
      相关资源
      最近更新 更多