erlangchicagobosserlangweb

Erlang ChicagoBoss passing url get parameters


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>

Solution

  • Check what you're getting in RequestBody

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