Ring

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(以“Ring 是 Clojure web 应用库,受 Python WSGI 和 Ruby [https://rack.github.io/ Rack] 启发。 ==指南== ==图集== ==链接== *[https://github.com/...”为内容创建页面)
 
(指南)
第2行: 第2行:
  
 
==指南==
 
==指南==
 +
vim project.clj
 +
:dependencies [[org.clojure/clojure "1.8.0"]
 +
                [ring/ring-core "1.4.0"]
 +
                [ring/ring-jetty-adapter "1.4.0"]])
 +
 +
$ lein deps
 +
 +
$ lein repl
 +
user=> (ns hello-world.core)
 +
hello-world.core=> (defn handler [request]
 +
              #_=> {:status 200
 +
              #_=> :headers {"Content-Type" "text/html"}
 +
              #_=> :body "Hello World"})
 +
hello-world.core=> (use 'ring.adapter.jetty)
 +
hello-world.core=> (use 'hello-world.core)
 +
hello-world.core=> (run-jetty handler {:port 3000})
 +
http://localhost:3000/
  
 
==图集==
 
==图集==

2016年5月10日 (二) 06:55的版本

Ring 是 Clojure web 应用库,受 Python WSGI 和 Ruby Rack 启发。

指南

vim project.clj

:dependencies [[org.clojure/clojure "1.8.0"]
                [ring/ring-core "1.4.0"]
                [ring/ring-jetty-adapter "1.4.0"]])

$ lein deps

$ lein repl

user=> (ns hello-world.core)
hello-world.core=> (defn handler [request]
             #_=> {:status 200
             #_=> :headers {"Content-Type" "text/html"}
             #_=> :body "Hello World"})
hello-world.core=> (use 'ring.adapter.jetty)
hello-world.core=> (use 'hello-world.core)
hello-world.core=> (run-jetty handler {:port 3000})
http://localhost:3000/

图集

链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱