dogweather

dogweather

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?

Showing Posts 1 to 4

fuelen

fuelen

Yes, I’d write a helper which allows to do the job in router

redirect("/oregon_revised_statutes", to: "/statuses")
redirect("/ors/volume/:number", to: "/statutes/ors_volume_:number")

and maybe use a different file which defines these routes. Another service is overkill IMO.

EDIT: ah, I see, domain name had been changed as well. Then another service is OK :slight_smile:

AstonJ

AstonJ

Nice! Haven’t used it in a long time but I’ve used (Apache) mod_rewrite for redirects in the past - I’d be curious to know it performs compared to your Phoenix app :smiley:

dimitarvp

dimitarvp

These days I’d reach for nginx or caddy but admittedly the approach chosen by OP is more programmable and likely a little bit more manageable.

AstonJ

AstonJ

Yeah I’d agree - I hated having to write rewrite rules using mod_rewrite :lol:

Could be a great selling point if the Phoenix app performs just as well :003:

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New
nseaSeb
I’ve just put together a small POC exploring PDF inspection from Elixir/Phoenix: The idea is pretty simple: drag & drop a PDF in a...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews