diff --git a/README.md b/README.md
index 4668b1e..cf56aa7 100644
--- a/README.md
+++ b/README.md
@@ -80,10 +80,15 @@ $ rebar3 as test lfe test
## Usage [↟](#table-of-contents)
+
```shell
$ rebar3 lfe run
```
+```shell
+$ podman load --input image.tar
+$ podman run whatever
+```
## Roadmap [↟](#roadmap)
@@ -93,6 +98,8 @@ $ rebar3 lfe run
☑ Provide an example of serving htmx from LFE.
+☐ Use Lanes as the router (less hassle than current)
+
☑ - Add github actions for quick test results.
☐ Add github action to create container
diff --git a/rebar.config b/rebar.config
index 237dcaa..773caf7 100644
--- a/rebar.config
+++ b/rebar.config
@@ -1,13 +1,13 @@
{erl_opts, [{src_dirs, ["src", "test"]}]}.
-
+
{deps, [
{lfe, "2.1.2"},
{ltest, "0.13.5"},
- {barista, "0.3.4"},
- {lanes, "0.3.3"},
- {lanes_barista, "0.3.3"},
+ {barista, "0.3.2"},
+ {logjam, "1.2.2"},
+ {lanes, "0.3.0-rc4"},
+ {lanes_barista, "0.3.0-rc4"},
{proper, "1.4.0"}
-
]}.
{plugins, [
diff --git a/scripts/main.lfe b/scripts/main.lfe
index 393ef62..4ef74d3 100644
--- a/scripts/main.lfe
+++ b/scripts/main.lfe
@@ -7,4 +7,6 @@
(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))))
+ (timer:sleep 30000000)
+)
diff --git a/src/barista-routes.lfe b/src/barista-routes.lfe
index 15afd59..a36c40b 100644
--- a/src/barista-routes.lfe
+++ b/src/barista-routes.lfe
@@ -2,6 +2,8 @@
(export (do 1)
(handle 3)))
+(include-lib "include/macros.lfe")
+(include-lib "logjam/include/logjam.hrl")
(defun do (httpd-req)
(let ((req (barista-request:->map httpd-req)))
@@ -15,41 +17,67 @@
"Cache-Control: no-store"
"\r\n"))
-(defun handle
- (('GET (list (binary ("chapter1"))) (= `#m(body ,body) req))
- (progn
- (lfe_io:format "Serving up get on chapter 1~n" '())
- (let* ((headers (generate-headers))
- (body (list (template:load "chapter1.html"))))
- (lfe_io:format "headers: ~p~n" `(,headers))
- (barista:response 200 headers body))))
-
- (('GET (list (binary ("chapter2"))) (= `#m(body ,body) req))
- (progn
- (lfe_io:format "Serving up get on chapter 2~n" '())
- (let* ((headers (generate-headers))
- (body (list (template:load "chapter2.html"))))
- (lfe_io:format "headers: ~p~n" `(,headers))
- (barista:response 200 headers body))))
-
- (('POST (list (binary ("chapter1-clicked")) )(= `#m(body ,body) req))
- (progn
- (let* ((headers (generate-headers))
- (body (list (binary " This is just a html fragment "))))
- (lfe_io:format "headers: ~p~n" `(,headers))
- (barista:response 200 headers body))))
-
- ;; catch all, i guess.
- ((method path (= `#m(body ,body) req))
- (progn
- (lfe_io:format "METHOD IS ATOM?: ~p~n" (list (is_atom method)))
- (lfe_io:format "method: ~p~n" (list method))
- (lfe_io:format "catch all~n" '())
- (lfe_io:format "path: ~p~n" (list path))
- (let* ((headers (generate-headers))
- (body (list (template:load "index.html"))))
- (lfe_io:format "headers: ~p~n" `(,headers))
- (barista:response 200 headers body)))))
+
+(defroutes
+ ;; This macro generates the handle/3 function used by do/1.
+ ;;
+ ;; top-level
+ ('GET #"/"
+ (progn
+ (logger:debug "This is getting old, why doesnt this match ")
+ (barista-response:ok (erlang:binary_to_list (template:load "index.html")))))
+
+ ;; single order operations
+ ('POST #"/order"
+ (progn
+ (barista-response:ok "ORDER PLACED")))
+
+ ('GET #"/test/"
+ (barista-response:ok "sure fine whatever"))
+
+ ;; error conditions
+ ('ALLOWONLY ('GET 'POST 'PUT 'DELETE)
+ (barista-response:method-not-allowed))
+ ('NOTFOUND
+ (progn
+ (logger:info "Bad path probably.. ?")
+ (barista-response:not-found "Bad path!: invalid operation."))))
+
+;; (defun handle
+;; (('GET (list (binary ("chapter1"))) (= `#m(body ,body) req))
+;; (progn
+;; (lfe_io:format "Serving up get on chapter 1~n" '())
+;; (let* ((headers (generate-headers))
+;; (body (list (template:load "chapter1.html"))))
+;; (lfe_io:format "headers: ~p~n" `(,headers))
+;; (barista:response 200 headers body)))))
+
+;; (('GET (list (binary ("chapter2"))) (= `#m(body ,body) req))
+;; (progn
+;; (lfe_io:format "Serving up get on chapter 2~n" '())
+;; (let* ((headers (generate-headers))
+;; (body (list (template:load "chapter2.html"))))
+;; (lfe_io:format "headers: ~p~n" `(,headers))
+;; (barista:response 200 headers body))))
+
+;; (('POST (list (binary ("chapter1-clicked")) )(= `#m(body ,body) req))
+;; (progn
+;; (let* ((headers (generate-headers))
+;; (body (list (binary " This is just a html fragment "))))
+;; (lfe_io:format "headers: ~p~n" `(,headers))
+;; (barista:response 200 headers body))))
+
+;; ;; catch all, i guess.
+;; ((method path (= `#m(body ,body) req))
+;; (progn
+;; (lfe_io:format "METHOD IS ATOM?: ~p~n" (list (is_atom method)))
+;; (lfe_io:format "method: ~p~n" (list method))
+;; (lfe_io:format "catch all~n" '())
+;; (lfe_io:format "path: ~p~n" (list path))
+;; (let* ((headers (generate-headers))
+;; (body (list (template:load "index.html"))))
+;; (lfe_io:format "headers: ~p~n" `(,headers))
+;; (barista:response 200 headers body)))))
diff --git a/src/barista-server-app.lfe b/src/barista-server-app.lfe
index eac96a7..39f6de0 100644
--- a/src/barista-server-app.lfe
+++ b/src/barista-server-app.lfe
@@ -2,14 +2,20 @@
(behaviour application)
(export all))
+
+(include-lib "logjam/include/logjam.hrl")
+
+
(defun config ()
'(#(port 8888)
#(server_name "barista-server-app")
#(modules (barista-routes))))
(defun start ()
+ (logger:set_primary_config #m(level all))
+ (logjam:set-config `#(path ,"config/sys.config"))
+ (logger:alert "Starting barista server: ")
(barista:start (config))
-;; (: timer sleep 'infinity)
)
(defun start (_type _args)