Comments (6)
1.2.0-SNAPSHOT
has the new api key :formats
(: format
is asserted away), here's the doc for for the key:
- :formats for Muuntaja middleware. Value can be a valid muuntaja options-map,
a Muuntaja instance or nil (to unmount it). See
https://github.com/metosin/muuntaja/wiki/Configuration for details.
Comments welcome.
from compojure-api.
I actually wrote a middleware to generate csv format. And that would be very helpful.
Could you help me on another related subject? I have a middleware that transform the body of the ring response. I replace a map by a raw string. Unfortunately, the string is escaped. I don't really see how to prevent this transformation.
(defn wrap-excel [handler]
(fn [request]
(let [new-request (update-in request [:meta :produces]
#(concat % ["application/csv"]))
response (handler new-request)]
(if (= (get-in response [:headers "accept"]) "application/csv")
(to-csv result)
result))))
where to-csv
do mostly an (update-in response [:body] map-to-csv-raw-string)
thanks
from compojure-api.
Hmm.. escaped? Not sure, but there is a serialization hint, allowing one to
return raw primitives, might help, see:
https://github.com/metosin/compojure-api/blob/master/test/compojure/api/middleware_test.clj
https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L31-L33
does this help?
On 16 Dec 2014 11:19, "Yann Esposito" [email protected] wrote:
I actually wrote a middleware to generate csv format. And that would be
very helpful.Could you help me on another related subject? I have a middleware that
transform the body of the ring response. I replace a map by a raw string.
Unfortunately, the string is escaped. I don't really see how to prevent
this transformation.(defn wrap-excel [handler](fn [request]
%28let [new-request %28update-in request [:meta :produces]
#%28concat % ["application/csv"]%29%29
result %28handler new-request%29]
%28if %28= %28get-in request [:headers "accept"]) "application/csv")
(to-csv result)
result))))where to-csv do mostly an (update-in (handler request) [:body]
map-to-csv-raw-string)thanks
—
Reply to this email directly or view it on GitHub
#61 (comment)
.
from compojure-api.
Thanks, it helped me a lot! You rocks!
I had to write it like that:
(assoc response
:compojure.api.meta/serializable? false
:body (to-csv (:body res)))
from compojure-api.
we are about to release a new web-formats library soon. Will cover this and more.
from compojure-api.
´1.2.0-alpha2´
from compojure-api.
Related Issues (20)
- spec coercion to int HOT 1
- OpenAPI? HOT 5
- Add {:coercion :select-schema} option
- muuntaja encoder modifying swagger.json output HOT 1
- Vulnerability issue in dependent lib
- Missing security and deprecated meta
- Memory use rises with requests HOT 3
- Can't get Swagger UI to provide interface for arbitrary query params HOT 2
- fix broken url link in docs
- Clj-kondo linting issue HOT 2
- Consider bumping to Compojure 1.7.0 or Compojure 1.6.3
- Mixing compojure.api.sweet/defapi and compojure.core/defroutes
- How do I specify an optional field when accepting multipart-params for a request?
- Compojure 2.x should be backwards compatible with 1.x HOT 3
- Automatically push `context` parameters into endpoints when safe HOT 3
- Calculate coercers/schemas outside contexts when not dependent on request
- Pull out static parts of an otherwise-dynamic context
- Compile to non-linear routing strategies
- Immutable `restructure` interface
- Potential memory leak
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compojure-api.