Erlang ChicagoBoss passing url get parameters

202 Views Asked by At

I would like to perform a simple operation that takes me hours to solve in erlang and ChicagoBoss:

Here is the url: http://example.com?string=some+string

Desired result:

some string

/controllers/index/example_index_controllers.erl

-module(example_index_controller, [Req, SessionID]).
-compile([export_all]).
index('GET', []) ->
Parameter = Req:query_param("string"),
{ok, [{data, Parameter  }]}.

result: /views/index/index.html

<b>{{ data }}</b>
1

There are 1 best solutions below

0
trex On BEST ANSWER

Check what you're getting in RequestBody

RequestBody = string:tokens(binary_to_list(Req:request_body()), "&")