Skip to content

Commit d5ad53f

Browse files
committed
feat: configure max_age for OGImageController in development and production
- Added a max_age configuration for AlgoraWeb.OGImageController in both dev.exs and prod.exs. - Updated the OGImageController to retrieve max_age from the configuration instead of using a hardcoded value.
1 parent 1d19562 commit d5ad53f

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

config/dev.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,5 @@ config :algora,
142142
plausible_url: System.get_env("PLAUSIBLE_URL"),
143143
assets_url: System.get_env("ASSETS_URL"),
144144
ingest_url: System.get_env("INGEST_URL")
145+
146+
config :algora, AlgoraWeb.OGImageController, max_age: 0

config/prod.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@ config :algora,
3232
assets_url: System.get_env("ASSETS_URL"),
3333
ingest_url: System.get_env("INGEST_URL")
3434

35+
config :algora, AlgoraWeb.OGImageController, max_age: 600
36+
3537
# Runtime production configuration, including reading
3638
# of environment variables, is done on config/runtime.exs.

lib/algora_web/controllers/og_image_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule AlgoraWeb.OGImageController do
77

88
@opts [type: "png", width: 1200, height: 630, scale_factor: 1]
99

10-
@max_age 600
10+
defp max_age, do: Algora.config([AlgoraWeb.OGImageController, :max_age])
1111

1212
def generate(conn, %{"path" => path}) do
1313
object_path = Path.join(["og"] ++ path ++ ["og.png"])

0 commit comments

Comments
 (0)