路由到phoenix-framework中的静态页面 [英] Route to a static page in phoenix-framework

查看:54
本文介绍了路由到phoenix-framework中的静态页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的网站运行带有凤凰后端的angularJS前端.我希望我的根路由将用户定向到包含我的angular客户的静态目录中的预构建页面,然后使用phoenix运行API.过去,我是通过像这样的路线匹配在红宝石上做到这一点的:

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?

推荐答案

暂时不行.您需要先创建一个控制器,然后在该控制器中:

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

这篇关于路由到phoenix-framework中的静态页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆