JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

joy/route

joy


    function
    /usr/local/lib/janet/joy/router.janet on line 284, column 1

    (route method url handler-name &opt handler-alias)


1 exampleSign in to add an example
Loading...
(import joy)

# Given a handler
(defn handle-func [request]
  (joy/text/plain (string "Hi " ((request :params) :name))))
# joy/route will attach it to a route
(joy/route :get "/hi/:name" :handle-func)
# without needing to pass the route(s) to joy/app
(def app (joy/app {}))
(joy/server app 9002)
# visit at localhost:9002/hi/bob
veqqqPlayground