Skip to main content

src/plume@permitted_cross_domain_policies.erl

-module(plume@permitted_cross_domain_policies).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plume/permitted_cross_domain_policies.gleam").
-export([to_string/1]).
-export_type([permitted_cross_domain_policies/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(
    " X-Permitted-Cross-Domain-Policies\n"
    "\n"
    " This response header tells clients (mainly Adobe Flash Player and Adobe\n"
    " Acrobat) which cross-domain policy files (`crossdomain.xml`) are permitted\n"
    " on the current site. Setting the header to `none` prevents any policy\n"
    " files from being loaded, which is the most restrictive option.\n"
    "\n"
    " See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Permitted-Cross-Domain-Policies).\n"
).

-type permitted_cross_domain_policies() :: none |
    master_only |
    by_content_type |
    by_ftp_filename |
    all |
    none_this_response.

-file("src/plume/permitted_cross_domain_policies.gleam", 32).
?DOC(" Encode as the `X-Permitted-Cross-Domain-Policies` header value.\n").
-spec to_string(permitted_cross_domain_policies()) -> binary().
to_string(Value) ->
    case Value of
        none ->
            <<"none"/utf8>>;

        master_only ->
            <<"master-only"/utf8>>;

        by_content_type ->
            <<"by-content-type"/utf8>>;

        by_ftp_filename ->
            <<"by-ftp-filename"/utf8>>;

        all ->
            <<"all"/utf8>>;

        none_this_response ->
            <<"none-this-response"/utf8>>
    end.