Fork me on GitHub
#reitit
<
2019-05-23
>
ikitommi05:05:09

@scot-brown yes, it's identical to compojure.core/routes. But it's not intended to be used inside of the reitit route tree, but to help combine routes in the default-routes branch.

ben.mumford07:05:39

hi reitit. i'm writing a web api using reitit that returns a very large response. how do i go about zipping it up. i've tried adding https://github.com/clj-commons/ring-gzip-middleware to the list of middleware but it doesn't seem to affect the response time:

{;;:reitit.middleware/transform dev/print-request-diffs
           :data {:coercion reitit.coercion.spec/coercion
                  :muuntaja m/instance
                  :middleware [;; query-params & form-params
                               parameters/parameters-middleware
                               ;; content-negotiation
                               muuntaja/format-negotiate-middleware
                               ;; encoding response body
                               muuntaja/format-response-middleware
                               ;; exception handling
                               exception/exception-middleware
                               ;; decoding request body
                               muuntaja/format-request-middleware
                               ;; coercing response bodies
                               coercion/coerce-response-middleware
                               ;; coercing request parameters
                               coercion/coerce-request-middleware

                               ;; gziping
                               ring-gzip/wrap-gzip
                               ]}}

ikitommi07:05:18

@ben.mumford620 response time? does it effect the response size? I think you should put that on top of the chain, so that it’s the last thing what happens. now it’s the first thing that happens after a handler returns (and things like response coercion doesn’t work as they can’t see inside the zip)

ben.mumford07:05:17

thanks i'll give it a go

ikitommi07:05:43

if you need it just for one route, you do something like:

["/large"
  {:middleware ^:prepend [ring-gzip/wrap-gzip]
   :handler ...}]
, and it will be added as first in the list. Thanks to awesome merge-hints of meta-merge (https://github.com/weavejester/meta-merge#metadata)

👍 4