Function Phoenix.Endpoint.url/0 is undefined or private


When I try to use:

IO.inspect Phoenix.Endpoint.url()

it says:

function Phoenix.Endpoint.url/0 is undefined or private

I tried to call another function from Phoenix like IO.inspect Phoenix.json_library() and it works (returns “Jason”).

Why does it say that the function url/0 is undefined or private?

Phoenix.Endpoint.url/0 is a callback.
Try YourAppWeb.Endpoint.url instead.


Thank you. How do these callbacks work actually?

When you use Phoenix.Endpoint, the __using__ macro is invoked ( This function unquotes several other blocks of code (

Here you can see where url/0 is implemented (

The callback dictates which functions must be defined when you implement a Behavior. url/0 is one of these functions. Phoenix, of course, provides default implementations for all of these core Behaviors.