File size: 503 Bytes
88211d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
defmodule PlausibleWeb.Plugs.InternalStatsApiVersion do
  @moduledoc """
  Adds the `x-api-version` response header to all internal
  stats API responses. See `Plausible.InternalStatsApiVersion`
  for version tracking and rollout logic.
  """
  @behaviour Plug
  import Plug.Conn

  @impl true
  def init(opts), do: opts

  @impl true
  def call(conn, _opts) do
    version = Plausible.InternalStatsApiVersion.effective_version()
    put_resp_header(conn, "x-api-version", to_string(version))
  end
end