Skip to content

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

@frenchy64

Description

@frenchy64

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions