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

Calculate coercers/schemas outside contexts when not dependent on request #464

Open
frenchy64 opened this issue Apr 23, 2024 · 0 comments
Open

Comments

@frenchy64
Copy link
Collaborator

frenchy64 commented Apr 23, 2024

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))
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

No branches or pull requests

1 participant