Liking cljdoc? Tell your friends :D

unifier.response

A Clojure(Script) library for unified responses.

A Clojure(Script) library for unified responses.
raw docstring

*allow-override?*clj/s

A flag to allow overriding already associated keys in the registry. Overrides are disabled by default.

A flag to allow overriding already associated keys in the registry.
Overrides are disabled by default.
raw docstring

*registryclj/s

A registry for associating unified response types with http response types.

A registry for associating unified response types with http response types.
raw docstring

->clj/smacro

(-> expr & forms)

This macro is the same as clojure.core/some->, but the check is done using the predicate error? of the IUnifiedResponse protocol and the substitution occurs as in macro -> (the thread-first macro).

This macro is the same as `clojure.core/some->`, but the check is done
using the predicate `error?` of the `IUnifiedResponse` protocol and
the substitution occurs as in macro `->` (the `thread-first` macro).
raw docstring

->>clj/smacro

(->> expr & forms)

This macro is the same as clojure.core/some->>, but the check is done using the predicate error? of the IUnifiedResponse protocol and the substitution occurs as in macro ->> (the thread-last macro).

This macro is the same as `clojure.core/some->>`, but the check is done
using the predicate `error?` of the `IUnifiedResponse` protocol and
the substitution occurs as in macro `->>` (the `thread-last` macro).
raw docstring

?->clj/smacro

(?-> & forms)

The safe version of the macro -> (the thread-first macro).

The safe version of the macro `->` (the `thread-first` macro).
raw docstring

?->>clj/smacro

(?->> & forms)

The safe version of the macro ->> (the thread-last macro).

The safe version of the macro `->>` (the `thread-last` macro).
raw docstring

as-acceptedclj/s

(as-accepted data)
(as-accepted data meta)

Returns unified ::accepted response.

Returns unified `::accepted` response.
raw docstring

as-busyclj/s

(as-busy data)
(as-busy data meta)

Returns unified ::busy response.

Returns unified `::busy` response.
raw docstring

as-conflictclj/s

(as-conflict data)
(as-conflict data meta)

Returns unified ::conflict response.

Returns unified `::conflict` response.
raw docstring

as-createdclj/s

(as-created data)
(as-created data meta)

Returns unified ::created response.

Returns unified `::created` response.
raw docstring

as-deletedclj/s

(as-deleted data)
(as-deleted data meta)

Returns unified ::deleted response.

Returns unified `::deleted` response.
raw docstring

as-errorclj/s

(as-error data)
(as-error data meta)
(as-error type data meta)

Returns unified ::error response.

Returns unified `::error` response.
raw docstring

as-exceptionclj/s

(as-exception data)
(as-exception data meta)

Returns unified ::exception response.

Returns unified `::exception` response.
raw docstring

as-forbiddenclj/s

(as-forbidden data)
(as-forbidden data meta)

Returns unified ::forbidden response.

Returns unified `::forbidden` response.
raw docstring

as-httpclj/s

(as-http x)

Returns ring response by the given unified response type.

Returns ring response by the given unified response type.
raw docstring

as-incorrectclj/s

(as-incorrect data)
(as-incorrect data meta)

Returns unified ::incorrect response.

Returns unified `::incorrect` response.
raw docstring

as-interruptedclj/s

(as-interrupted data)
(as-interrupted data meta)

Returns unified ::interrupted response.

Returns unified `::interrupted` response.
raw docstring

as-not-foundclj/s

(as-not-found data)
(as-not-found data meta)

Returns unified ::not-found response.

Returns unified `::not-found` response.
raw docstring

as-successclj/s

(as-success data)
(as-success data meta)
(as-success type data meta)

Returns unified ::success response.

Returns unified `::success` response.
raw docstring

as-unauthorizedclj/s

(as-unauthorized data)
(as-unauthorized data meta)

Returns unified ::unauthorized response.

Returns unified `::unauthorized` response.
raw docstring

as-unavailableclj/s

(as-unavailable data)
(as-unavailable data meta)

Returns unified ::unavailable response.

Returns unified `::unavailable` response.
raw docstring

as-unknownclj/s

(as-unknown data)
(as-unknown data meta)

Returns unified ::unknown response.

Returns unified `::unknown` response.
raw docstring

as-unsupportedclj/s

(as-unsupported data)
(as-unsupported data meta)

Returns unified ::unsupported response.

Returns unified `::unsupported` response.
raw docstring

as-warningclj/s

(as-warning data)
(as-warning data meta)

Returns unified ::warning response.

Returns unified `::warning` response.
raw docstring

cljs?clj

(cljs? env)

Checks &env in macro and returns true if that cljs env. Otherwise false.

Checks &env in macro and returns `true` if that cljs env. Otherwise `false`.
raw docstring

error-typesclj/s

Common error types.

Common `error` types.
raw docstring

error?clj/s

(error? x)

Returns true if the given value is instance of unifier.response/UnifiedError. Otherwise false.

Returns `true` if the given value is instance of `unifier.response/UnifiedError`. Otherwise `false`.
raw docstring

get-dataclj/s

(get-data x)

Returns data of response.

Returns `data` of response.
raw docstring

get-metaclj/s

(get-meta x)

Returns meta of response.

Returns `meta` of response.
raw docstring

get-typeclj/s

(get-type x)

Returns type of response.

Returns `type` of response.
raw docstring

IUnifiedResponseclj/sprotocol

-get-metaclj/s

(-get-meta _)

Returns meta of response.

Returns `meta` of response.

-error?clj/s

(-error? _)

Returns true if the given value is instance of unifier.response/UnifiedError. Otherwise false.

Returns `true` if the given value is instance of `unifier.response/UnifiedError`. Otherwise `false`.

-success?clj/s

(-success? _)

Returns true if the given value is instance of unifier.response/UnifiedSuccess. Otherwise false.

Returns `true` if the given value is instance of `unifier.response/UnifiedSuccess`. Otherwise `false`.

-set-dataclj/s

(-set-data _ data)

Sets data of response.

Sets `data` of response.

-set-typeclj/s

(-set-type _ type)

Sets type of response.

Sets `type` of response.

-set-metaclj/s

(-set-meta _ meta)

Sets meta of response.

Sets `meta` of response.

-get-typeclj/s

(-get-type _)

Returns type of response.

Returns `type` of response.

-response?clj/s

(-response? _)

Returns true if the given value is implements unifier.response/IUnifiedResponse protocol. Otherwise false.

Returns `true` if the given value is implements `unifier.response/IUnifiedResponse` protocol. Otherwise `false`.

-get-dataclj/s

(-get-data _)

Returns data of response.

Returns `data` of response.

(link unified http & kvs)

Same as link! but allows overrides by default.

Same as `link!` but allows overrides by default.
raw docstring

link!clj/s

(link! unified http & kvs)

Associate unified response type with http response type.

Returns:

  • true - when all unified response types successfully linked

Params:

  • unified - unified response type
  • http - http response type

Throws:

  • ExceptionInfo:
    • throws when the given http response type is unknown
    • throws when the given unified response type has been already associated with http response type
Associate unified response type with http response type.

Returns:
  * `true` - when all unified response types successfully linked

Params:
  * `unified` - unified response type
  * `http`    - http response type

Throws:
  * `ExceptionInfo`:
    - throws when the given http response type is unknown
    - throws when the given unified response type has been already associated with http response type
raw docstring

responseclj/s

(response x)
(response type x)

Returns ring response, where:

  • :status - gets from the registry by the unified response type
  • :header - empty map
  • :body - unwrapped unified response
Returns ring response, where:
* `:status` - gets from the registry by the unified response type
* `:header` - empty map
* `:body`   - unwrapped unified response
raw docstring

response?clj/s

(response? x)

Returns true if the given value is implements unifier.response/IUnifiedResponse protocol. Otherwise false.

Returns `true` if the given value is implements `unifier.response/IUnifiedResponse` protocol. Otherwise `false`.
raw docstring

safeclj/smacro

(safe body)
(safe body handler)

Extended version of try-catch.

Extended version of try-catch.
raw docstring

set-dataclj/s

(set-data x data)

Sets data of response.

Sets `data` of response.
raw docstring

set-metaclj/s

(set-meta x meta)

Sets meta of response.

Sets `meta` of response.
raw docstring

set-typeclj/s

(set-type x type)

Sets type of response.

Sets `type` of response.
raw docstring

success-typesclj/s

Common success types.

Common `success` types.
raw docstring

success?clj/s

(success? x)

Returns true if the given value is instance of unifier.response/UnifiedSuccess. Otherwise false.

Returns `true` if the given value is instance of `unifier.response/UnifiedSuccess`. Otherwise `false`.
raw docstring

unwrapclj/s

(unwrap response)

Returns unwrapped unified response (as map).

Returns unwrapped unified response (as map).
raw docstring

with-defaultclj/s

(with-default x)

Returns default http response type by the given unified response type.

Returns: If the given unified response is:

  • success - :unifier.response.http/ok
  • error - :unifier.response.http/bad-request
  • ::error, ::exception - :unifier.response.http/internal-server-error Otherwise nil.
Returns `default` http response type by the given unified response type.

Returns:
  If the given unified response is:
   * `success`                - `:unifier.response.http/ok`
   * `error`                  - `:unifier.response.http/bad-request`
   * `::error`, `::exception` - `:unifier.response.http/internal-server-error`
  Otherwise `nil`.
raw docstring

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

× close