{"id":6297,"date":"2011-10-16T14:31:57","date_gmt":"2011-10-16T05:31:57","guid":{"rendered":"http:\/\/fukata.org\/?p=6297"},"modified":"2017-08-11T22:58:48","modified_gmt":"2017-08-11T22:58:48","slug":"garbled-characterscompojure-and-fleet","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/6297\/","title":{"rendered":"Compojure + Fleet\u3067\u6587\u5b57\u5316\u3051"},"content":{"rendered":"
\u4e45\u3057\u3076\u308a\u306bCompojure + Fleet\u306a\u74b0\u5883\u3092\u89e6\u3063\u3066\u3044\u3066\u4f55\u6c17\u306a\u304f\u65e5\u672c\u8a9e\u304c\u8a18\u8f09\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8868\u793a\u3057\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u3001\u65e9\u901f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u65e5\u672c\u8a9e\u3092\u8ffd\u52a0\u3057\u3066\u8868\u793a\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u300c??\u300d\u3068\u3044\u3046\u98a8\u306b\u898b\u4e8b\u306b\u6587\u5b57\u5316\u3051\u304c\u767a\u751f\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<\/p>\n
<\/p>\n
\u305d\u306e\u6642\u306e\u30b3\u30fc\u30c9\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n
core.clj<\/strong><\/p>\n index.html.fleet<\/strong><\/p>\n \u4f55\u304c\u304a\u304b\u3057\u3044\u306e\u304b\u8abf\u3079\u3066\u3044\u3066\u3001\u901a\u5e38\u306e\u30b5\u30a4\u30c8\u3068\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u30d8\u30c3\u30c0\u30fc\u3092\u898b\u6bd4\u3079\u3066\u307f\u308b\u3068\u3001Content-Type\u306e\u30d8\u30c3\u30c0\u30fc\u304c\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u305d\u3053\u3067\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3057\u3066\u3042\u3052\u308b\u3068\u6b63\u5e38\u306bContent-Type\u30d8\u30c3\u30c0\u30fc\u3082\u751f\u6210\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u3001\u6587\u5b57\u5316\u3051\u304c\u89e3\u6d88\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n \u6bce\u56deheaders\u3092\u66f8\u304f\u306e\u304c\u6020\u3044\u3068\u3044\u3046\u65b9\u306f\u3001\u4e0b\u8a18\u3060\u3051\u3067\u3082\u5927\u4e08\u592b\u306e\u3088\u3046\u3067\u3059\u3002\u307e\u3060\u3001Compojure\u306e\u4e2d\u8eab\u3092\u898b\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u5909\u306a\u3084\u308a\u65b9\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3002<\/p>\n \u4e0a\u8a18\u306eFleet Setup<\/strong>\u3067\u884c\u3063\u3066\u3044\u308bextend-protocol\u90e8\u5206\u3067\u3046\u307e\u3044\u3053\u3068\u7e8f\u3081\u4e0a\u3052\u3089\u308c\u308b\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u3082\u601d\u3044\u307e\u3059\u304c\u3068\u308a\u3042\u3048\u305a\u3001\u30d9\u30bf\u3067\u3042\u308d\u3046\u3084\u308a\u65b9\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n \u8ffd\u8a18\uff1a2011-11-17 10:31<\/strong> src\/compojure\/response.clj<\/strong><\/p>\n \u8ffd\u8a18\uff1a2011-11-17 10:39<\/strong> \u4e45\u3057\u3076\u308a\u306bCompojure + Fleet\u306a\u74b0\u5883\u3092\u89e6\u3063\u3066\u3044\u3066\u4f55\u6c17\u306a\u304f\u65e5\u672c\u8a9e\u304c\u8a18\u8f09\u3055\u308c\u305f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u8868\u793a\u3057\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u3001\u65e9\u901f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u65e5\u672c\u8a9e\u3092\u8ffd\u52a0\u3057\u3066\u8868\u793a\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u300c??\u300d\u3068\u3044\u3046\u98a8\u306b\u898b … \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,907],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6297"}],"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=6297"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6297\/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=6297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=6297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=6297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\r\n(ns compojuretest.core\r\n (:use compojure.core\r\n compojure.response\r\n ring.adapter.jetty\r\n [ring.util.response :only (response content-type)]\r\n fleet)\r\n (:require [compojure.route :as route]))\r\n\r\n;; =============================================\r\n;; Fleet Setup \r\n;; =============================================\r\n(def filters [ \r\n \"js\" :str\r\n \"html\" :xml\r\n \"fleet\" :bypass])\r\n\r\n(fleet-ns tpl \"templates\" filters)\r\n\r\n(extend-protocol Renderable\r\n fleet.util.CljString\r\n (render [this _] (response (.toString this))))\r\n\r\n;; =============================================\r\n;; Routes\r\n;; =============================================\r\n(defroutes app \r\n (GET \"\/\" [] (tpl\/index {})))\r\n\r\n;; =============================================\r\n;; Run Server\r\n;; =============================================\r\n(defn -main []\r\n (let [port (Integer\/parseInt (get (System\/getenv) \"PORT\" \"8080\"))]\r\n (run-jetty app {:port port})))\r\n<\/pre>\n
\r\n< !DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"https:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\r\n\r\n\r\n \r\n
\u30c6\u30b9\u30c8<\/h1>\r\n<\/body>\r\n<\/html> \r\n<\/pre>\n
\r\n;; =============================================\r\n;; Routes\r\n;; =============================================\r\n(defroutes app\r\n (GET \"\/\" [] {:headers {\"Content-Type\" \"text\/html; charset=utf8\"}\r\n :body (str (tpl\/index {}))}))\r\n<\/pre>\n
\r\n;; =============================================\r\n;; Routes\r\n;; =============================================\r\n(defroutes app\r\n (GET \"\/\" [] (str (tpl\/index {}))))\r\n<\/pre>\n
\nCompojure\u306eresponse.clj\u3092\u898b\u305f\u3068\u3053\u308d\u3001String\u306e\u5834\u5408\u306fContent-Type\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u306e\u3067str\u95a2\u6570\u3092\u631f\u3080\u5834\u5408\u306b\u624b\u52d5\u3067\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n\r\n(extend-protocol Renderable\r\n nil\r\n (render [_ _] nil) \r\n String\r\n (render [body _]\r\n (-> (response body)\r\n (content-type \"text\/html; charset=utf-8\")))\r\n APersistentMap\r\n (render [resp-map _]\r\n (merge (response \"\") resp-map))\r\n IFn\r\n (render [func request]\r\n (render (func request) request))\r\n IDeref \r\n (render [ref request]\r\n (render (deref ref) request)) \r\n File \r\n (render [file _] (response file))\r\n ISeq\r\n (render [coll _] (-> (response coll)\r\n (content-type \"text\/html; charset=utf-8\")))\r\n InputStream\r\n (render [stream _] (response stream))\r\n URL\r\n (render [url _]\r\n (if (= \"file\" (.getProtocol url))\r\n (response (io\/as-file url))\r\n (response (io\/input-stream url)))))\r\n<\/pre>\n
\nextend-protocol\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u7de8\u96c6\u3059\u308b\u3053\u3068\u3067\u3001str\u95a2\u6570\u3092\u631f\u307e\u306a\u304f\u3066\u3082\u6b63\u5e38\u306b\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n\r\n(extend-protocol Renderable\r\n fleet.util.CljString\r\n (render [this _] (-> (response (.toString this))\r\n (content-type \"text\/html; charset=utf-8\"))))\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"