Switch routing from compojure to reitit
This commit is contained in:
parent
f44a743660
commit
0469f59e80
4 changed files with 18 additions and 15 deletions
|
|
@ -1,20 +1,22 @@
|
|||
(ns heyarne.all-my-friends.server
|
||||
(:require [org.httpkit.server :as http]
|
||||
[compojure.core :as router]
|
||||
[compojure.route :as route]
|
||||
[clojure.java.io :as io]
|
||||
[ring.logger :as logger]
|
||||
[reitit.ring :as ring]
|
||||
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
|
||||
[heyarne.all-my-friends.env :refer [env]])
|
||||
(:gen-class))
|
||||
|
||||
(router/defroutes app
|
||||
(router/POST "/upload" [& args]
|
||||
(println "/upload" args)
|
||||
{:status 400})
|
||||
(router/GET "/" []
|
||||
(slurp (io/resource "public/index.html")))
|
||||
(route/resources "/")
|
||||
(route/not-found "Not found."))
|
||||
(def app
|
||||
(ring/ring-handler
|
||||
(ring/router
|
||||
[["/"
|
||||
{:get (fn [_]
|
||||
{:status 200
|
||||
:body (io/file (io/resource "public/index.html"))})}]
|
||||
["/upload"
|
||||
{:post (fn [req]
|
||||
{:status 400
|
||||
:body "To be done"})}]])))
|
||||
|
||||
(defonce server (atom nil))
|
||||
|
||||
|
|
@ -27,7 +29,7 @@
|
|||
(defn -main [& args]
|
||||
(println "Starting server on port" (env :port))
|
||||
(reset! server (-> #'app
|
||||
(logger/wrap-with-logger)
|
||||
(wrap-defaults (assoc site-defaults :static {:resources "public"}))
|
||||
(http/run-server {:port (env :port)}))))
|
||||
|
||||
#_(-main)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
(ns heyarne.all-my-friends.views
|
||||
(:require [reagent.core :as r]
|
||||
[applied-science.js-interop :as j]
|
||||
[heyarne.all-my-friends.facemesh :refer [webcam-facemesh]]
|
||||
[heyarne.all-my-friends.visualize :as vis]))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue