(apply-response-augmentations response)
Process the raw response from the parser looking for lambdas that were added by
top-level Fulcro queries and mutations via
augment-response
. Runs each in turn and accumulates their effects. The result is
meant to be a Ring response (and is used as such by handle-api-request
.
Process the raw response from the parser looking for lambdas that were added by top-level Fulcro queries and mutations via `augment-response`. Runs each in turn and accumulates their effects. The result is meant to be a Ring response (and is used as such by `handle-api-request`.
(augment-response core-response ring-response-fn)
Adds a lambda to the given data core-response
such that apply-response-augmentations
will use it to morph the raw Ring response in which the core-response
is embedded
(the core response becomes the :body
).
The ring-response-fn
is a (fn [resp] resp')
that will be passed a raw (possibly empty)
Ring response which it can modify and return.
Use this function when you need to add information into the handler response, for example when you need to add cookies or session data. Example:
(defmutation my-mutate
...
(augment-response
{:uid 42} ; your regular response
#(assoc-in % [:session :user-id] 42))) ; a function resp -> resp
If the parser has multiple responses that use augment-response
they will all be applied.
The first one will receive an empty map as input. Only top level values
of your response will be checked for augmented response (i.e. primarily mutation responses).
See apply-response-augmentations
, which is used by handle-api-request
, which in turn is the
primary implementation element of wrap-api
.
Adds a lambda to the given data `core-response` such that `apply-response-augmentations` will use it to morph the raw Ring response in which the `core-response` is embedded (the core response becomes the `:body`). The `ring-response-fn` is a `(fn [resp] resp')` that will be passed a raw (possibly empty) Ring response which it can modify and return. Use this function when you need to add information into the handler response, for example when you need to add cookies or session data. Example: (defmutation my-mutate ... (augment-response {:uid 42} ; your regular response #(assoc-in % [:session :user-id] 42))) ; a function resp -> resp If the parser has multiple responses that use `augment-response` they will all be applied. The first one will receive an empty map as input. Only top level values of your response will be checked for augmented response (i.e. primarily mutation responses). See `apply-response-augmentations`, which is used by `handle-api-request`, which in turn is the primary implementation element of `wrap-api`.
The default response to return when a Transit request is malformed.
The default response to return when a Transit request is malformed.
(generate-response
{:keys [status body headers] :or {status 200} :as input-response})
Generate a Fulcro-compatible response containing at least a status code, headers, and body. You should pre-populate at least the body of the input-response. The content type of the returned response will always be pegged to 'application/transit+json'.
Generate a Fulcro-compatible response containing at least a status code, headers, and body. You should pre-populate at least the body of the input-response. The content type of the returned response will always be pegged to 'application/transit+json'.
(handle-api-request query query-processor)
Given a parser and a query: Runs the parser on the query,
and generates a standard Fulcro-compatible response, and augment the raw Ring response with
any augment handlers that were indicated on top-level mutations/queries via
augment-response
.
Given a parser and a query: Runs the parser on the query, and generates a standard Fulcro-compatible response, and augment the raw Ring response with any augment handlers that were indicated on top-level mutations/queries via `augment-response`.
(reader in)
(reader in opts)
Create a transit reader. This reader can handler the tempid type. Can pass transit reader customization opts map.
Create a transit reader. This reader can handler the tempid type. Can pass transit reader customization opts map.
(wrap-api handler {:keys [uri parser]})
Wrap Fulcro API request processing. Required options are:
:uri
- The URI on the server that handles the API requests.:parser
- A function (fn [eql-query] eql-response)
that can process the query.IMPORTANT: You must install wrap-transit-response
and wrap-transit-params
to your middleware below this.
Wrap Fulcro API request processing. Required options are: - `:uri` - The URI on the server that handles the API requests. - `:parser` - A function `(fn [eql-query] eql-response)` that can process the query. IMPORTANT: You must install `wrap-transit-response` and `wrap-transit-params` to your middleware below this.
(wrap-transit-params handler)
(wrap-transit-params handler options)
Middleware that parses the body of Transit requests into a map of parameters, which are added to the request map on the :transit-params and :params keys. Accepts the following options: :malformed-response - a response map to return when the JSON is malformed :opts - a map of options to be passed to the transit reader Use the standard Ring middleware, ring.middleware.keyword-params, to convert the parameters into keywords.
Middleware that parses the body of Transit requests into a map of parameters, which are added to the request map on the :transit-params and :params keys. Accepts the following options: :malformed-response - a response map to return when the JSON is malformed :opts - a map of options to be passed to the transit reader Use the standard Ring middleware, ring.middleware.keyword-params, to convert the parameters into keywords.
(wrap-transit-response handler)
(wrap-transit-response handler options)
Middleware that converts responses with a map or a vector for a body into a Transit response. Accepts the following options: :encoding - one of #{:json :json-verbose :msgpack} :opts - a map of options to be passed to the transit writer
Middleware that converts responses with a map or a vector for a body into a Transit response. Accepts the following options: :encoding - one of #{:json :json-verbose :msgpack} :opts - a map of options to be passed to the transit writer
(writer out)
(writer out opts)
Create a transit writer. This writer can handler the tempid type. Can pass transit writer customization opts map.
Create a transit writer. This writer can handler the tempid type. Can pass transit writer customization opts map.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close