Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Route to a static page in phoenix-framework

I want to run an angularJS front end with a phoenix backend for my site. I would like my root route to direct the user to a pre-built page in the static directory which contains my angular client and then use phoenix to run the API. I have done this in the past with ruby on rails by route matching like this:

get '/', to: redirect('/foobar.html')  

Is there a way to do something similar with phoenix?

like image 857
CoolTapes Avatar asked Apr 28 '15 12:04

CoolTapes


1 Answers

Not right now. You need to create a controller and then in the controller:

defmodule MyApp.RootController do
  use MyApp.Web, :controller

  plug :action

  def index(conn, _params) do
    redirect conn, to: "/foobar.html"
  end
end
like image 84
José Valim Avatar answered Sep 21 '22 14:09

José Valim