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

Commit

Permalink
Loading from templates mostly working.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmealing committed Oct 28, 2023
1 parent b84b13c commit 6c6c449
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/barista-routes.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

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

(defun handle
Expand All @@ -26,7 +28,7 @@
"Cache-Control: no-cache"
"Cache-Control: no-store"
"\r\n"))
(body (load-template "/tmp/hello.txt")))
(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))))
Expand Down
3 changes: 2 additions & 1 deletion src/untitled-project.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
;;; -----------

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

0 comments on commit 6c6c449

Please sign in to comment.