Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Rename untitled-project to "untitled_project" as module names with hy…
Browse files Browse the repository at this point in the history
…phens break things.
  • Loading branch information
wmealing committed Oct 28, 2023
1 parent 6c6c449 commit 68fc78b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scripts/main.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
(defun main (args)
(let ((script-name (escript:script_name)))
(io:format "Running script '~s' with args ~p ...~n" `(,script-name ,args))
(io:format "~p~n" `(,(untitled-project:start)))))
(io:format "~p~n" `(,(untitled_project:start)))))
27 changes: 14 additions & 13 deletions src/barista-routes.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@

;; fixme, error handling on file.
(defun load-template (template-file)
(let* ((priv-dir (: code priv_dir 'untitled))
(let* ((priv-dir (: code priv_dir 'untitled_project))
(file-path (++ priv-dir "/" template-file))
((tuple status contents) (: file read_file file-path)))
(list contents )))


(defun handle
((method path (= `#m(body ,body) req))
"Example handler that displays whatever is passed through."
(lfe_io:format "method: ~p~n" (list method))
(lfe_io:format "path: ~p~n" (list path))
(let* ((headers '("Content-Type: text/html"
"Cache-Control: no-cache"
"Cache-Control: no-store"
"\r\n"))
(body (load-template "hello.txt")))
(lfe_io:format "headers: ~p~n" `(,headers))
(lfe_io:format "body: ~p~n~n" `(,body))
(barista:response 200 headers body))))
((method path (= `#m(body ,body) req))
"Example handler that displays whatever is passed through."
(lfe_io:format "method: ~p~n" (list method))
(lfe_io:format "path: ~p~n" (list path))
(let* ((headers '("Content-Type: text/html"
"Cache-Control: no-cache"
"Cache-Control: no-store"
"\r\n"))
(body (load-template "hello.txt")))
(lfe_io:format "headers: ~p~n" `(,headers))
(lfe_io:format "body: ~p~n~n" `(,body))
(barista:response 200 headers body))))

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{application, 'untitled-project', [
{application, 'untitled_project', [
{description, "A run-ready LFE script"},
{vsn, git},
{registered, []},
Expand Down
5 changes: 3 additions & 2 deletions src/untitled-project.lfe → src/untitled_project.lfe
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defmodule untitled-project
(defmodule untitled_project
(export
(start 0)))

Expand All @@ -8,5 +8,6 @@

(defun start ()
;; FIXME: this should probably be ensure-all-started, or something.
(application:ensure_started 'untitled-project)
(application:ensure_all_started 'inets)
(application:ensure_all_started 'untitled_project)
(barista-server-app:start))

0 comments on commit 68fc78b

Please sign in to comment.