Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support async Ring #10

Merged
merged 1 commit into from
Jul 1, 2019
Merged

Conversation

camsaul
Copy link
Contributor

@camsaul camsaul commented Jul 1, 2019

Minor tweaks to the middleware so it will can be used with either a 3-airty async handler (added in Ring 1.6.0) or with a 1-arity synchronous handler.

@camsaul camsaul requested a review from danielcompton as a code owner July 1, 2019 19:32
@camsaul camsaul force-pushed the support-async-ring branch 2 times, most recently from 9a32b9e to f0b93a2 Compare July 1, 2019 19:34
Copy link
Member

@danielcompton danielcompton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few notes here, but overall this looks good. Thanks!

(gzipped-response resp)
resp))
resp))))
(defn- wrap-gzip* [req {:keys [body status] :as resp}]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to gzip-request please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Would gzip-response make more sense? Because it's the response that's getting zipped, not the request. In the JSON middleware you linked they're going with json-response for the function that does the same thing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yes you're completely right.

([request respond raise]
(handler
request
(comp respond (partial wrap-gzip* request))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this match the style at https://github.com/ring-clojure/ring-json/blob/0.5.0-beta1/src/ring/middleware/json.clj#L125? Composing multiple functions like this is not that easy to understand immediately.

(fn
([request]
(wrap-gzip* request (handler request)))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the space between arities?

@camsaul
Copy link
Contributor Author

camsaul commented Jul 1, 2019

@danielcompton made the changes you requested and added a test as well. Let me know if this works for you

@danielcompton danielcompton merged commit fa5057e into clj-commons:master Jul 1, 2019
Copy link
Member

@danielcompton danielcompton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@danielcompton
Copy link
Member

Released in 0.1.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants