How to add more than one parameters in ChicagoBoss route

46 Views Asked by At

I am trying to get the following link to work: http://localhost:8001/name/jason/grey

and the routes definition:

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

and then in my controller

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

I get the following error message

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

Seems I am not getting it right with the routes definition, any help?

1

There are 1 best solutions below

0
Sunday Okpokor On

Finally got it working, should in case there is anyone with the same issue. Instead of using list of tuples in the route definitions to define the parameters, use tuples separated by commas e.g

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