metosin / metosin/compojure-api
Calculate coercers/schemas outside contexts when not dependent on request
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.1k
- Forks
- 146
- PR merge metrics
- No merged PRs in 30d
Description
Coercers aren't really amenable to this at the moment, and use a memoized cache to get around this limitation (but given that equivalent Schema's are often not equal, might not be totally effective), but the idea is:
(context "/foo" req
(GET "/" []
:body [body :- MySchema]
...))
=>
(let [coercer (cache-coercion s/Int)]
(context "/foo" req
(GET "/" []
:body [body :- coercer]
...))
Or perhaps an even more general optimization that would cache all sorts of things like merge-parameters and all the other args to routes/map->Route and the route itself, even under a dynamic context.
(let [rs (GET "/" []
:body [body :- coercer]
...)]
(context "/foo" req
rs))
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 examining the coercer cache, dynamic context handling, and the routes/map->Route and merge-parameters paths mentioned in the issue. The issue needs an agreed optimization scope and a way to verify that request-independent work is calculated outside contexts without changing route behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- backend-api-design, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100