Skip to content
Browse files

prepare for 0.3.0 release

  • Loading branch information...
1 parent 31500a7 commit d62a822fece563a3462e520ab2f139ba5b184f5a @ngrunwald committed Mar 11, 2013
Showing with 24 additions and 17 deletions.
  1. +5 −2 Changes.md
  2. +5 −1 README.md
  3. +2 −2 project.clj
  4. +12 −12 src/ring/middleware/format_params.clj
View
7 Changes.md
@@ -1,6 +1,6 @@
# Changes for ring-middleware-format
-## 0.3.0-SNAPSHOT
+## 0.3.0
### Breaking Changes
- `wrap-format-response` encodes the body with the first format
(`:json` by default) when unable to find an encoder matching the
@@ -14,9 +14,12 @@
- Added `:json-kw` and `:yaml-kw` formats and wrapper to have
keywords keys in `:params` and `:body-params`
+### Bugfixes
+ - Use readers in `*data-readers*` for *edn* ( _Roman Scherer_ )
+
### Other
- Better formatted doctrings ( _Anthony Grimes_ )
-
+
## 0.2.4
### Bugfixes
- Allow empty request body as per Ring Spec ( _Roman Scherer_ )
View
6 README.md
@@ -37,7 +37,7 @@ The available formats are:
- `:json-kw` JSON with keywodized keys in `:params` and `:body-params`
- `:yaml` YAML format
- `:yaml-kw` YAML format with keywodized keys in `:params` and `:body-params`
- - `:edn` edn (native cljure format). It uses *clojure.tools.edn* and never evals code
+ - `:edn` edn (native cljure format). It uses *clojure.tools.edn* and never evals code, but uses the custom tags from `*data-readers*`
- `:yaml-in-html` yaml in a html page (useful for browser debugging)
Your routes should return raw clojure data structures where everything inside can be handled by the default encoders (no Java objects or fns mostly). If a route returns a _String_, _File_ or _InputStream_, nothing will be done. If no format can be deduced from the **Accept** header or the format specified is unknown, the first format in the vector will be used (_JSON_ by default).
@@ -101,6 +101,10 @@ For exemple, this will cause all json formatted responses to be encoded in *iso-
```
+ You can implement the wrapper from scratch by using either or both `wrap-format-params` and `wrap-format-response`. For now, see the docs of each and how the other formats were implemented for help doing this.
+## Future Work ##
+
++ Add [MessagePack](http://msgpack.org/) format and support binary payloads.
+
## See Also ##
This module aims to be both easy to use and easy to extend to new formats. However, it does not try to help with every apect of building a RESTful API, like proper error handling and method dispatching. If that is what you are looking for, you could check the modules which function more like frameworks:
View
4 project.clj
@@ -1,12 +1,12 @@
-(defproject ring-middleware-format "0.3.0-SNAPSHOT"
+(defproject ring-middleware-format "0.3.0"
:description "Ring middleware for parsing parameters and emitting
responses in various formats."
:url "https://github.com/ngrunwald/ring-middleware-format"
:license {:name "Eclipse Public License - v 1.0"
:url "http://www.eclipse.org/legal/epl-v10.html"
:distribution :repo
:comments "same as Clojure"}
- :dependencies [[org.clojure/clojure "1.4.0"]
+ :dependencies [[org.clojure/clojure "1.5.0"]
[org.clojure/core.memoize "0.5.2"]
[ring "1.1.8"]
[cheshire "5.0.1"]
View
24 src/ring/middleware/format_params.clj
@@ -79,18 +79,18 @@
[handler & {:keys [predicate decoder charset handle-error]}]
(fn [{:keys [#^InputStream body] :as req}]
(try
- (if-let [byts (slurp-to-bytes body)]
- (if (predicate req)
- (let [body (:body req)
- #^String char-enc (if (string? charset) charset (charset (assoc req :body byts)))
- bstr (String. byts char-enc)
- fmt-params (decoder bstr)
- req* (assoc req
- :body-params fmt-params
- :params (merge (:params req)
- (when (map? fmt-params) fmt-params)))]
- (handler req*))
- (handler (assoc req :body (ByteArrayInputStream. byts))))
+ (if (and body (> (.available body) 0) (predicate req))
+ (let [byts (slurp-to-bytes body)
+ body (:body req)
+ #^String char-enc (if (string? charset) charset (charset (assoc req :body byts)))
+ bstr (String. byts char-enc)
+ fmt-params (decoder bstr)
+ req* (assoc req
+ :body-params fmt-params
+ :params (merge (:params req)
+ (when (map? fmt-params) fmt-params))
+ :body (ByteArrayInputStream. byts))]
+ (handler req*))
(handler req))
(catch Exception e
(handle-error e handler req)))))

0 comments on commit d62a822

Please sign in to comment.
Something went wrong with that request. Please try again.