Returning simple "Hello World" from controller function without a view?

I want to quickly test a new controller to make sure I’ve established proper routing. Is there a simple way to have the function return a simple string WITHOUT having to dig into a view module? I was hoping for something like return "Hello world!" I can use an IO.puts statement to verify that things got there, but after that, I hit an error because I don’t know how to return a simple string.

1 Like

You can use text/2 to send a string as a response :slight_smile:

5 Likes

Just to demonstrate a full example here:

def index(conn, _opts) do
    text(conn, "Testing...")
end
2 Likes