defmodule TarakanWeb.InfestationRedirectController do
  @moduledoc """
  Permanent redirects from the pre-rename `/patterns` URLs to `/infestations`.
  """
  use TarakanWeb, :controller

  def index(conn, _params) do
    conn
    |> put_status(:moved_permanently)
    |> redirect(to: ~p"/infestations")
  end

  def show(conn, %{"pattern_key" => pattern_key}) do
    conn
    |> put_status(:moved_permanently)
    |> redirect(to: ~p"/infestations/#{pattern_key}")
  end
end
