~pepe/chidi

761b687c1daeb2d134171163e4de8cf3f4713a93 — Josef Pospíšil 6 months ago a10df15
Initialize handler in fn
1 files changed, 11 insertions(+), 11 deletions(-)

M examples/epsilon.janet
M examples/epsilon.janet => examples/epsilon.janet +11 -11
@@ 73,20 73,20 @@
    (ev/give c (math/random))
    (chidi/success "inced")))

(def handler
  (let [c (ev/chan)]
    (chidi/drive
      {"/" (index)
       "/launch.sse" launch
       "/state.sse" (state c)
       "/start" (start c)
       "/inc" (inc c)
       "/stop" (stop c)}
      chidi/journal)))
(defn handler []
  (def c (ev/chan))
  (chidi/drive
    {"/" (index)
     "/launch.sse" launch
     "/state.sse" (state c)
     "/start" (start c)
     "/inc" (inc c)
     "/stop" (stop c)}
    chidi/journal))

# Main entrypoint into the program. You can run it from Chidi's root with:
# `janet examples/alpha.janet`
(defn main [&]
  (print "Starting server")
  # Just start the server with `handler` function as a first argument.
  (chidi/start handler))
  (chidi/start (handler)))