The user accesses the following route: www.example.com/api/users/x
, where x is variable.
How to get x and create routes with dynamic responses?
Automatically translated.
For any company that currently uses Ruby on Rails, Phoenix Framework should be on your radar, because it adds considerable performance gains. To top that off, Phoenix makes it incredibly fast to build web applications.
In your router.ex you need to write something like following -
get "/api/users/:x", SomeController, :actionName
Now in your controller, you need to use patten matching to get the value of x from _params, ie:
def actionName(conn, %{"x" => x}) do
# now x is available here
end
For more details, http://www.phoenixframework.org/docs/controllers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With