Middleware for coercing and schema-validating requests and responses.
By default -- passing (constantly nil) for input-coercer and output-coercer -- ordinary schema validation is applied, with default string coercion for input uri-args and query-params and json coercion for the body (see schema.coerce). Schema validation errors will throw with a helpful error message.
In addition, custom RequestRelativeCoercionMatchers can be passed for input and output coercion, which enable the coercion of custom types in the input and output.
For examples, see the included 'examples/guesthouse' project.
Middleware for coercing and schema-validating requests and responses. By default -- passing (constantly nil) for input-coercer and output-coercer -- ordinary schema validation is applied, with default string coercion for input uri-args and query-params and json coercion for the body (see schema.coerce). Schema validation errors will throw with a helpful error message. In addition, custom RequestRelativeCoercionMatchers can be passed for input and output coercion, which enable the coercion of custom types in the input and output. For examples, see the included 'examples/guesthouse' project.
Default coercion matchers for request keys/responses. Can be rebound for now, better API for specifying matchers is TBD.
Default coercion matchers for request keys/responses. Can be rebound for now, better API for specifying matchers is TBD.
(coercing-walker context schema custom-matcher)
Inputs: [context :- s/Keyword schema custom-matcher :- RequestRelativeCoercionMatcher]
Take a context key, schema, and custom matcher, and produce a walker that returns the datum or throws an error for validation failure.
Inputs: [context :- s/Keyword schema custom-matcher :- RequestRelativeCoercionMatcher] Take a context key, schema, and custom matcher, and produce a walker that returns the datum or throws an error for validation failure.
(coercion-middleware {:keys [handler info]} input-coercer output-coercer)
Inputs: [{:keys [handler info]} :- schemas/AnnotatedHandler input-coercer :- RequestRelativeCoercionMatcher output-coercer :- RequestRelativeCoercionMatcher] Returns: schemas/AnnotatedHandler
Coerce and validate inputs and outputs. Use walkers to simultaneously coerce and validate inputs in a generous way (i.e., 1.0 in body will be cast to 1 in order to validate against a long schema), and outputs will be clientized to match the output schemas as specified by output-coercer. If custom coercion is not needed, (constantly nil) be passed as a no-op coercer.
Inputs: [{:keys [handler info]} :- schemas/AnnotatedHandler input-coercer :- RequestRelativeCoercionMatcher output-coercer :- RequestRelativeCoercionMatcher] Returns: schemas/AnnotatedHandler Coerce and validate inputs and outputs. Use walkers to simultaneously coerce and validate inputs in a generous way (i.e., 1.0 in body will be cast to 1 in order to validate against a long schema), and outputs will be clientized to match the output schemas as specified by output-coercer. If custom coercion is not needed, (constantly nil) be passed as a no-op coercer.
(request-walker input-coercer handler-info)
Given a custom input coercer, compile a function for coercing and validating requests (uri-args, query-params, and body).
Given a custom input coercer, compile a function for coercing and validating requests (uri-args, query-params, and body).
A coerce/CoercionMatcher whose data coercion function also takes the request. Useful for, e.g., client-relative presentation rules, expanding relative urls, etc.
A coerce/CoercionMatcher whose data coercion function also takes the request. Useful for, e.g., client-relative presentation rules, expanding relative urls, etc.
(response-walker output-coercer handler-info)
Given a custom output coercer, compile a function for coercing and validating response bodies. Other parts of the response map are not validated.
Given a custom output coercer, compile a function for coercing and validating response bodies. Other parts of the response map are not validated.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close