Skip to main content

src/plume@dns_prefetch_control.erl

-module(plume@dns_prefetch_control).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/plume/dns_prefetch_control.gleam").
-export([to_string/1]).
-export_type([dns_prefetch_control/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-DNS-Prefetch-Control\n"
    "\n"
    " This response header controls DNS prefetching, a feature by which browsers\n"
    " proactively perform domain name resolution on links, images, CSS, and other\n"
    " resources the user may navigate to. Prefetching improves performance but\n"
    " can leak information about which resources a page references to the user's\n"
    " DNS resolver.\n"
    "\n"
    " See the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-DNS-Prefetch-Control).\n"
).

-type dns_prefetch_control() :: on | off.

-file("src/plume/dns_prefetch_control.gleam", 22).
?DOC(" Encode as the `X-DNS-Prefetch-Control` header value.\n").
-spec to_string(dns_prefetch_control()) -> binary().
to_string(Value) ->
    case Value of
        on ->
            <<"on"/utf8>>;

        off ->
            <<"off"/utf8>>
    end.