Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.server.api-middleware

Standard Ring middleware for setting up servers to handle Fulcro requests. These assume you will be using a library like Pathom to create a parser that can properly dispatch resolution of requests. See the Developer's Guide or the Fulcro template for examples of usage.

Standard Ring middleware for setting up servers to handle Fulcro requests. These assume you will be using a library
like Pathom to create a parser that can properly dispatch resolution of requests. See the Developer's Guide or
the Fulcro template for examples of usage.
raw docstring

apply-response-augmentationsclj

(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`.
sourceraw docstring

augment-responseclj

(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`.
sourceraw docstring

default-malformed-responseclj

The default response to return when a Transit request is malformed.

The default response to return when a Transit request is malformed.
sourceraw docstring

generate-responseclj

(generate-response {:keys [status body] :or {status 200} :as input-response})

Generate a Fulcro-compatible response containing at least a status code, and body. You should pre-populate at least the body of the input-response.

Generate a Fulcro-compatible response containing at least a status code, and
body. You should pre-populate at least the body of the input-response.
sourceraw docstring

handle-api-requestclj

(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`.
sourceraw docstring

not-found-handlerclj

source

readerclj

(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.
sourceraw docstring

wrap-apiclj

(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 Fulcro's wrap-transit-response and wrap-transit-params, or other middleware that handles content negotiation, like https://github.com/metosin/muuntaja, to your list of middleware handlers after wrap-api.

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 Fulcro's `wrap-transit-response` and
`wrap-transit-params`, or other middleware that handles content negotiation,
like https://github.com/metosin/muuntaja, to your list of middleware
handlers after `wrap-api`.
sourceraw docstring

wrap-transit-paramsclj

(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.
sourceraw docstring

wrap-transit-responseclj

(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
sourceraw docstring

writerclj

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close