-module(plume@cross_origin_resource_policy).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plume/cross_origin_resource_policy.gleam").
-export([to_string/1]).
-export_type([cross_origin_resource_policy/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(
" Cross-Origin Resource Policy (CORP)\n"
"\n"
" This response header determines which origins are allowed to\n"
" read no-cors resource responses (e.g. those triggered by `<script>` and `<img>`).\n"
"\n"
" See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cross-Origin_Resource_Policy).\n"
).
-type cross_origin_resource_policy() :: same_site | same_origin | cross_origin.
-file("src/plume/cross_origin_resource_policy.gleam", 24).
?DOC(" Encode as the `Cross-Origin-Resource-Policy` header value.\n").
-spec to_string(cross_origin_resource_policy()) -> binary().
to_string(Value) ->
case Value of
same_site ->
<<"same-site"/utf8>>;
same_origin ->
<<"same-origin"/utf8>>;
cross_origin ->
<<"cross-origin"/utf8>>
end.