From 775bc596ac84f5b28b4e0e1654525a360002711f Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Fri, 5 Jan 2024 08:25:08 +0000 Subject: =?UTF-8?q?=F0=9F=94=80=20Add=20flags=20for=20configuring=20the=20?= =?UTF-8?q?server's=20host=20and=20port.=20(#33)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :sparkles: Add the option to include lustre_ui styles from a CDN. * :heavy_plus_sign: Add glint and argv as dependencies. * :sparkles: Use glint for cli args parsing. This adds support for user-configurable host and port, as well as the ability to opt-in to including lustre_ui's stylesheet with the --include-styles flag. --- src/http_ffi.erl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/http_ffi.erl') diff --git a/src/http_ffi.erl b/src/http_ffi.erl index e9de7e7..355fabd 100644 --- a/src/http_ffi.erl +++ b/src/http_ffi.erl @@ -1,7 +1,7 @@ -module(http_ffi). --export([serve/4, response_default_headers/0]). +-export([serve/3, response_default_headers/0]). -serve(Host, Port, OnStart, OnPortTaken) -> +serve({options, Host, Port, IncludeStyles}, OnStart, OnPortTaken) -> {ok, Pattern} = re:compile("name *= *\"(?.+)\""), {ok, Toml} = file:read_file("gleam.toml"), {match, [Name]} = re:run(Toml, Pattern, [{capture, all_names, binary}]), @@ -13,8 +13,13 @@ serve(Host, Port, OnStart, OnPortTaken) -> "\n" " \n" " \n" - " Lustre preview server\n" - "\n" + " Lustre preview server\n", + case IncludeStyles of + true -> + <<" \n">>; + false -> + <<"">> + end/binary, "