Open vinhnglx opened 7 years ago
[debug] Processing by Kitty.HelloController.world/2
Parameters: %{"name" => "vincent"}
Pipelines: [:browser]
This is an example about process a parameter from outside in Phoenix. The external parameters have string key "name" => "vincent"
, because external data can't safely be converted to atoms, because the atom table isn't garbage-collected.
This means atoms should not be generated dynamically for whatever reason;
web
directory is reloaded, and the code in lib
isn't. lib
is the perfect place to put long-running process, like Phoenix's Pub Sub system, database connection pool or any your own server processes.
|>
aka pipe operator, takes the value on the left and passes it as the first argument to the function on the right - it's calledpipelines
.There's a side benefit,
pipelines
are also functions - means you can make pipelines of pipelines. For example, what a Phoenix program might look like, using pipelines:The layers of Phoenix:
From a classic HTTP request.
Inside controller