This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns your-proj.models.posts | |
| (:require [coast.db :as db]) | |
| (:refer-clojure :exclude [update])) | |
| (def columns [:title :body]) | |
| (defn all [] | |
| (db/query :posts/all)) | |
| (defn find-by-id [id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns simple | |
| (:require [coast.core :as coast])) | |
| (defn home [request] | |
| (coast/ok "You're coasting on clojure!")) | |
| (def app (-> (coast/get "/" home) | |
| (coast/wrap-coast-defaults))) | |
| (defn -main [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns your-app.core | |
| (require [trail.core :as trail] | |
| [your-app.controllers.items :as items])) | |
| [your-app.controllers.tags :as tags])) | |
| (def routes | |
| (-> (trail/resource :items) | |
| (trail/resource :tags))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (def protected-routes (-> (get "/" (fn [r] "GET /")) | |
| (get "/sign-out" (fn [r] "GET /sign-out")))) | |
| (defn middleware [handler] | |
| (fn [request] | |
| (if (= 1 2) | |
| (handler request) | |
| (throw (Exception. "Nope"))))) | |
| (def routes (-> (wrap-routes middleware protected-routes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defroutes app-routes | |
| (trail/get "/items" items/index) | |
| (trail/get "/items/:id" items/show) | |
| (trail/get "/items/:id/new" items/new!) | |
| (trail/get "/items/:id/edit" items/edit) | |
| (trail/post "/items" items/create) | |
| (trail/put "/items/:id" items/update) | |
| (trail/delete "/items/:id" items/delete)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns your-app.core | |
| (require [trail.core :as trail] | |
| [org.httpkit.server :as server] | |
| [ring.middleware.defaults :as ring-defaults] | |
| [your-app.controllers.items :as items])) | |
| (def routes | |
| (-> (trail/get "/items" items/index) | |
| (trail/get "/items/:id" items/show) | |
| (trail/get "/items/:id/new" items/new!) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| [:get "/items"] items/index | |
| [:get "/items/:id"] items/show | |
| [:get "/items/:id/new"] items/new! | |
| [:get "/items/:id/edit"] items/edit | |
| [:post "/items"] items/create | |
| [:put "/items/:id"] items/update | |
| [:delete "/items/:id"] items/delete | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns trail-usage.core | |
| (:require [trail.core :as trail])) | |
| (def routes | |
| (-> (trail/get "/items" items/index) | |
| (trail/get "/items/:id" items/show) | |
| (trail/get "/items/:id/new" items/new!) | |
| (trail/get "/items/:id/edit" items/edit) | |
| (trail/post "/items" items/create) | |
| (trail/put "/items/:id" items/update) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns trail.core | |
| (:require [clout.core :as clout]) | |
| (:refer-clojure :exclude [get])) | |
| (defn route | |
| ([method route-map uri f] | |
| (assoc route-map [method uri] f)) | |
| ([method uri f] | |
| (route method {} uri f))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns my-blog.views.home | |
| (:require [my-blog.components :as c])) | |
| (defn index [] | |
| (c/layout | |
| (c/center | |
| "Welcome to my blog!"))) |