(respond-as martian http-client)
Adds an interceptor that simulates wrapping a response into the http-client
implementation-specific returned type.
Implementation of HTTP requests — as provided by target HTTP clients (httpkit, clj-http, cljs-http, ...) — may give
responses wrapped in an implementation-specific type, e.g. promise or core.async
channel. As your production code
will expect these response types this interceptor lets you simulate those response wrappers.
You only need to call this if you have a martian
instance created without the standard HTTP-specific interceptors,
i.e. those found in martian.httpkit
, martian.clj-http
and so on.
Removes all interceptors that would perform real HTTP operations.
Adds an interceptor that simulates wrapping a response into the `http-client` implementation-specific returned type. Implementation of HTTP requests — as provided by target HTTP clients (httpkit, clj-http, cljs-http, ...) — may give responses wrapped in an implementation-specific type, e.g. promise or `core.async` channel. As your production code will expect these response types this interceptor lets you simulate those response wrappers. You only need to call this if you have a `martian` instance created without the standard HTTP-specific interceptors, i.e. those found in `martian.httpkit`, `martian.clj-http` and so on. Removes all interceptors that would perform real HTTP operations.
(respond-with martian responses)
Adds an interceptor that simulates the server responding with the supplied responses
.
See docstrings of respond-with-constant
and respond-with-contextual
for details.
Removes all interceptors that would perform real HTTP operations.
Adds an interceptor that simulates the server responding with the supplied `responses`. See docstrings of `respond-with-constant` and `respond-with-contextual` for details. Removes all interceptors that would perform real HTTP operations.
(respond-with-constant martian response-map)
Adds an interceptor that simulates the server responding with responses retrieved from a given response-map
.
The response-map
maps a :route-name
to a response (plain value) or a unary function that, given the request,
returns a response.
Removes all interceptors that would perform real HTTP operations.
Adds an interceptor that simulates the server responding with responses retrieved from a given `response-map`. The `response-map` maps a `:route-name` to a response (plain value) or a unary function that, given the request, returns a response. Removes all interceptors that would perform real HTTP operations.
(respond-with-contextual martian response-fn)
Adds an interceptor that simulates the server responding with responses retrieved via a given response-fn
.
The response-fn
is a unary function that, given the ctx
, returns a response.
It provides even more flexibility than respond-with-constant
by allowing one to leverage the ctx
internals
for response production, e.g. directly use :params
to avoid JSON decoding/encoding round trips. Be careful
though, since this may result in the production of responses becoming "less realistic".
Removes all interceptors that would perform real HTTP operations.
Adds an interceptor that simulates the server responding with responses retrieved via a given `response-fn`. The `response-fn` is a unary function that, given the `ctx`, returns a response. It provides even more flexibility than `respond-with-constant` by allowing one to leverage the `ctx` internals for response production, e.g. directly use `:params` to avoid JSON decoding/encoding round trips. Be careful though, since this may result in the production of responses becoming "less realistic". Removes all interceptors that would perform real HTTP operations.
(respond-with-generated martian response-types)
Adds an interceptor that simulates the server responding with responses generated from the handler response schemas.
The response-types
maps a :route-name
to a response type which can be :random
(default, any HTTP status code),
:success
(HTTP status codes 200-399), or :error
(HTTP status codes 400-599).
Removes all interceptors that would perform real HTTP operations.
Adds an interceptor that simulates the server responding with responses generated from the handler response schemas. The `response-types` maps a `:route-name` to a response type which can be `:random` (default, any HTTP status code), `:success` (HTTP status codes 200-399), or `:error` (HTTP status codes 400-599). Removes all interceptors that would perform real HTTP operations.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close