Compojure is an open source web framework for the Clojure programming language. It emphasizes a thin I/O layer and a functional approach to web development.
Compojure is an open source web framework for the Clojure programming language. It emphasizes a thin I/O layer and a functional approach to web development.
Clojure Web Development with Ring March 27 2010 This post provides an introduction Clojure web development with Ring, a Clojure web application library. If you are just getting started with Clojure web development or if you are interested in the new Ring 0.2 release, this is a great place to start. Before getting started, ensure that you have Leiningen 1.1.0 installed. We will be using Leiningen v
CompojureとLeiningenを使って、Webアプリを作るためのメモ。 Compojure Clojure用のWebフレームワーク。バージョン0.4.0からサーバ-Compojure間のインターフェイス/ミドルウェアの部分はRingというライブラリに分けられています。 Compojure Leiningen 使用するライブラリの依存関係を管理したり、プロジェクトのビルドをしてくれるツール。 Leiningen プロジェクトを作る Leiningenでプロジェクトを作ります。 % lein new helloweb Created new project in: helloweb % cd helloweb % tree . |-- README |-- project.clj |-- src | `-- helloweb | `-- core.clj `-- test `-- he
URLの扱い ルートの定義 ;; (http-method route-path bindings & body) (GET "/" [] "index page") これは、ローカルで起動した時にはhttp://locahost:8080/にアクセスした際に"index page"をステータス200で返します。 で、ルートのパターンにはパラメータを含むことができます。 (GET "/page/:name" [name] (str "You reached page/" name)) リクエストされたURIが"/page/**"にマッチすると、"**"の値が引数としてnameに格納されます。この場合、http://localhost:8080/page/testにアクセスすれば"You reached page/test"と表示されるようになります。 ルートパスの部分にはワイルドカード、正
Compojureは、Clojure用の小規模なWebアプリ・フレームワークです。 Compojureを使うには、project.cljを次のように変更します。 (defproject helloweb "1.0.0-SNAPSHOT" :description "FIXME: write" :dependencies [[org.clojure/clojure "1.2.0"] [org.clojure/clojure-contrib "1.2.0"] [compojure "0.5.3"] ;Webアプリ・フレームワーク [ring/ring "0.3.1"]] ;RingはWebサーバを抽象化した層です。 ;CompojureはRingをベースにしています。 :main helloweb.core; 実行可能JARを作る場合に指定します。 ; helloweb.core/-main
ので、超訳してみる。 原文は、http://groups.google.com/group/compojure/browse_thread/thread/3c507da23540da6e 4. HTML以降はまだない。 1. ハンドラ Compojureでは、HTTPリクエストとHTTPレスポンスはClojureのマップで表される。 ハンドラはリクエストのマップを引数に取り、レスポンスのマップを返す関数である。 { リクエスト } --> ハンドラ --> { レスポンス } レスポンスのマップは3つのキーで構成される。 :status (必須、整数) HTTPステータスコード :headers (必須、マップ) HTTPヘッダ名と値のマップ :body (オプショナル、{String, ISeq, File, InputStream}) HTTPレスポンスボディと
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く