This has been a super-useful app for me and Phoenix is ridic fast and efficient with memory. Here’s the gist of it. There are a lot more entries in the actual app:
In router.ex
:
get("/oregon_revised_statutes", RedirectController, :ors_statutes)
get("/ors/volume/:number", RedirectController, :ors_volume)
And in redirect_controller.ex
:
def ors_statutes(conn, _), do: perm_redirect(conn, to: "#{@opl_url}/statutes")
def ors_volume(conn, %{"number" => number}) do
perm_redirect(conn, to: "#{@opl_url}/statutes/ors_volume_#{number}")
end
I’ve got all my old deprecated domain names pointed at this app, and it redirects to the new servers. Architecture-wise, it’s been a success: Usually, these legacy redirects would be in my actual app (unrelated code), or in a service like Cloudflare (good, but gets expensive.) The separate redirect server keeps these legacy business concerns (reallly SEO concerns) out of my production business app. And it will run on the cheapest Gigalixir instance.
I’m not a huge Phoenix expert. Anybody doing this a different way?