Skip to main content

src/plume@origin_agent_cluster.erl

-module(plume@origin_agent_cluster).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plume/origin_agent_cluster.gleam").
-export([to_string/1]).
-export_type([origin_agent_cluster/0]).

-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.

?MODULEDOC(
    " Origin-Agent-Cluster\n"
    "\n"
    " This response header requests that the document be placed in an\n"
    " origin-keyed agent cluster, isolating it from other same-site\n"
    " cross-origin documents. This prevents synchronous scripting access\n"
    " between them and may let the browser give the origin its own process\n"
    " or thread.\n"
    "\n"
    " See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Origin-Agent-Cluster).\n"
).

-type origin_agent_cluster() :: enabled | disabled.

-file("src/plume/origin_agent_cluster.gleam", 22).
?DOC(" Encode as the `Origin-Agent-Cluster` header value.\n").
-spec to_string(origin_agent_cluster()) -> binary().
to_string(Value) ->
    case Value of
        enabled ->
            <<"?1"/utf8>>;

        disabled ->
            <<"?0"/utf8>>
    end.