Can't figure out a simple form that passes data to an elixir app form phoenix interface

Hi,

I have a very simple need to pass two pieces of information to an elixir app that I have created and would like to make available via a Phoenix interface on the web.

The application takes an IP address and a subnet mask and then returns the IP and subnet mask octets in binary along with the calculated subnet and broadcast address in binary and decimal. All of the hard work is already done in making that happen via Elixir, but for the life of me I can’t seem to find a way to just pass those two parameters from the frontend to the backend without doing changesets.

What is the simplest way to just pass those two strings to an Elixir app and have it return the struct?

If you are dealing with Phoenix, the things you send in a POST request are given in the controller action’s params variable. Example here. Note that I’m not using changesets in this function. You are free to do with the parameters as you will, you don’t need to put them in a changeset.

1 Like

Maybe this…

def your_custom_action(conn, %{"ip" => ip, "subnet_mask" => sm}) do
  result = calculate_whatever(ip, sm)
  text(conn, result)
end
2 Likes