{"id":6498,"date":"2011-11-15T03:03:12","date_gmt":"2011-11-14T18:03:12","guid":{"rendered":"http:\/\/fukata.org\/?p=6498"},"modified":"2017-08-11T22:58:48","modified_gmt":"2017-08-11T22:58:48","slug":"compojure-pre-routes","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/6498\/","title":{"rendered":"Compojure\u306eroutes\u3067\u524d\u51e6\u7406\u3092\u884c\u3046"},"content":{"rendered":"

Noir\u3067\u306f\u5404\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5f8c\u306e\u51e6\u7406\u306e\u524d\u306b\u884c\u3046\u524d\u51e6\u7406\u3092pre-route\u3068\u3057\u3066\u5b9a\u7fa9\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u304c\u3001Compojure\u81ea\u4f53\u306b\u306f\u305d\u306e\u6a5f\u80fd\u306f\u7121\u3055\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001sandbar\u306estateful-session\u3092\u53c2\u8003\u306b\u3057\u3066\u3001\u4e0b\u8a18\u306e\u69d8\u306a\u30b3\u30fc\u30c9\u3067\u5b9f\u73fe\u3057\u307e\u3057\u305f\u3002<\/p>\n

<\/p>\n

\r\n(defroutes app-routes\r\n  (GET \"\/\" {}\r\n    \"Hello World\"))\r\n\r\n(defn wrap-pre*\r\n  [handler]\r\n  (fn [request]\r\n    (let [response (handler request)]\r\n      (when response\r\n        ;; ==========\r\n        ;; \u524d\u51e6\u7406\r\n        ;; ==========\r\n        response))))\r\n\r\n(defn wrap-pre\r\n  ([handler]\r\n   (wrap-pre handler {}))\r\n  ([handler options]\r\n   (-> handler\r\n     wrap-pre*)))\r\n\r\n(def app\r\n  (-> app-routes\r\n    (wrap-pre)\r\n    (wrap-stateful-session)))\r\n    \r\n(defn -main []\r\n  (let [port (Integer\/parseInt (get (System\/getenv) \"PORT\" \"8080\"))]\r\n    (run-jetty (handler\/site app) {:port port})))\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Noir\u3067\u306f\u5404\u3001\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u5f8c\u306e\u51e6\u7406\u306e\u524d\u306b\u884c\u3046\u524d\u51e6\u7406\u3092pre-route\u3068\u3057\u3066\u5b9a\u7fa9\u3067\u304d\u308b\u3088\u3046\u3067\u3059\u304c\u3001Compojure\u81ea\u4f53\u306b\u306f\u305d\u306e\u6a5f\u80fd\u306f\u7121\u3055\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001sandbar\u306estateful-sessi … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[900],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6498"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=6498"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6498\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=6498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=6498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=6498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}