• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ring: Web Apps in Idiomatic Clojure
 

Ring: Web Apps in Idiomatic Clojure

on

  • 17,310 views

 

Statistics

Views

Total Views
17,310
Views on SlideShare
17,185
Embed Views
125

Actions

Likes
25
Downloads
165
Comments
0

2 Embeds 125

http://www.slideshare.net 120
http://us-w1.rockmelt.com 5

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ring: Web Apps in Idiomatic Clojure Ring: Web Apps in Idiomatic Clojure Presentation Transcript

    • Ring Web Apps in Idiomatic Clojure Mark McGranaghan January 23, 2010
    • About Mark Bowdoin College ’10 Clojure user since 2008 Open source: http://github.com/mmcgrana
    • Motivation for Ring
    • Motivation for Ring Abstract HTTP
    • Motivation for Ring Abstract HTTP Write apps in idiomatic Clojure
    • Motivation for Ring Abstract HTTP Write apps in idiomatic Clojure Share code across web frameworks
    • Motivation for Ring Abstract HTTP Write apps in idiomatic Clojure Share code across web frameworks Deploy on a variety of web servers
    • Motivation for Ring Abstract HTTP Write apps in idiomatic Clojure Share code across web frameworks Deploy on a variety of web servers WSGI & Rack
    • The Ring Project
    • The Ring Project Spec
    • The Ring Project Spec Library
    • The Ring Project Spec Library Ecosystem
    • Overview of Ring
    • Overview of Ring Handlers are functions
    • Overview of Ring Handlers are functions that take requests as Clojure maps
    • Overview of Ring Handlers are functions that take requests as Clojure maps and return responses as Clojure map
    • Overview of Ring Handlers are functions that take requests as Clojure maps and return responses as Clojure map Adapters run handlers on a web server
    • Overview of Ring Handlers are functions that take requests as Clojure maps and return responses as Clojure map Adapters run handlers on a web server Middleware augments handlers
    • “Ring”
    • Request Map {:uri <String> :query-string <String> :request-method <Keyword> :headers <IPersistentMap> :body <InputStream> ... ...}
    • Response Map {:status <Integer> :headers <IPersistentMap> :body <String, ISeq, File, InputStream>}
    • Example: Hello World (defn app [req] {:status 200 :headers {"Content-Type" "text/html"} :body (str "Hi from " (:server-name req))})
    • Example: Hello World (defn app [req] {:status 200 :headers {"Content-Type" "text/html"} :body (str "Hi from " (:server-name req))}) (use ’ring.adapter.jetty) (run-jetty app {:port 8080})
    • Example: Hello World
    • Example: Stacktraces (defn app [req] ("o noes"))
    • Example: Stacktraces (defn app [req] ("o noes")) (use ’ring.adapter.jetty) (use ’ring.middleware.stacktrace) (run-jetty (wrap-stacktrace app) {:port 8080})
    • Example: Stacktraces
    • Example: Static Files (defn dynamic-app [req] (...))
    • Example: Static Files (defn dynamic-app [req] (...)) (use ’ring.middleware.file) (use ’ring.middleware.file-info) (def app (-> dynamic-app (wrap-file "public") (wrap-file-info)))
    • Example: Testability
    • Example: Testability (defn my-app [req] (...))
    • Example: Testability (defn my-app [req] (...)) (deftest not-found-error (let [req {:uri "/bogus/uri"} resp (my-app req)] (is (= 404 (:status resp)))))
    • Ring and Web Frameworks
    • Ring and Web Frameworks Foundation, not replacement
    • Ring and Web Frameworks Foundation, not replacement Avoid duplication and share code
    • Ring and Web Frameworks Foundation, not replacement Avoid duplication and share code Compojure, Conjure, Weld all targeting Ring
    • Ring and Web Frameworks Foundation, not replacement Avoid duplication and share code Compojure, Conjure, Weld all targeting Ring Compojure case study
    • Ring Middleware
    • Ring Middleware ring.middleware.reload: Automatically reload namespaces
    • Ring Middleware ring.middleware.reload: Automatically reload namespaces ring.middleware.params: Get request params as a map
    • Ring Middleware ring.middleware.reload: Automatically reload namespaces ring.middleware.params: Get request params as a map ring.middleware.cookies: Cookie jar abstraction
    • Other Components
    • Other Components ring.util.servlet: If you really want a Servlet
    • Other Components ring.util.servlet: If you really want a Servlet ring.adapter.httpcore: Adapter for HTTP Core library
    • Other Components ring.util.servlet: If you really want a Servlet ring.adapter.httpcore: Adapter for HTTP Core library ring.handler.dump: See the request map
    • Other Components ring.util.servlet: If you really want a Servlet ring.adapter.httpcore: Adapter for HTTP Core library ring.handler.dump: See the request map ring.examples.*: Runnable examples
    • Future Work
    • Future Work Middleware and utility extraction from frameworks
    • Future Work Middleware and utility extraction from frameworks Not a framework itself
    • Future Work Middleware and utility extraction from frameworks Not a framework itself More use in production?
    • Future Work Middleware and utility extraction from frameworks Not a framework itself More use in production? User needs?
    • Learn More http://github.com/mmcgrana/ring ring/example/*.clj ring/SPEC