metosin / metosin/compojure-api
Question about `route-middleware` usage
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 "2.0.0-alpha25"]
Problem
Hi,
We've been using compojure-api for a while and it works great, although we just came across with an issue.
We have couple of endpoints defined with route-middleware where we are trying to use some middlewares like logging or a prometheus related one. This works just fine if the endpoint is defined with GET or POST macros but for some reason the endpoints defined with resource won't get wrapped with the middleware functions. As far as I could see this issue had been present in the previous version with middleware function too.
We worked around this problem defining middlewares in resource macros' :middleware param.
My question would be that, is there a way to solve this problem? Using route-middleware endpoints defined without GET, POST etc. macros?
Thanks
Janos
Here is an example endpoint which is having problem:
(context "test-endpoint" []
(resource {:responses {200 {:schema domain/schema}}
:get {:parameters {:query-params domain/Request}
:handler (handle-request)}}))
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
Start by tracing how route-middleware is applied to GET and POST routes versus the resource macro, using the provided context/resource example as the reproduction. Compare this with the resource :middleware workaround; done means determining whether route-middleware can wrap resource endpoints and capturing the result in a test or clear documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100