metosin / metosin/compojure-api
Mixing compojure.api.sweet/defapi and compojure.core/defroutes
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.1k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
## Library Version(s)
[metosin/compojure-api "1.1.13"]
[compojure "1.6.1"]
## Problem
I have two handlers, defined as
(compojure.api.sweet/defapi restful-routes...)
(compojure.core/defroutes public-routes...)
When I combine them with
(compojure.core/routes #'restful-routes #'public-routes)
the POST requests to public routes loose :body parameters. The body comes through as org.eclipse.jetty.server.HttpInputOverHTTP, but it has been read somwhere in the middleware so its content is not available.
I blame compojure.api.sweet for this, because when I reverse the call order to
(compojure.core/routes #'public-routes #'restful-routes)
it works fine, the body streams in POST methods are available in both handlers.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with compojure-api 1.1.13 and compojure 1.6.1 using the two route definitions and both compojure.core/routes orderings. Trace the middleware applied by defapi and defroutes, then verify that POST body parameters remain available regardless of route order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100