A Clojure(Script) library for unified responses.
A Clojure(Script) library for unified responses.
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.
A registry for associating unified response types with http response types.
A registry for associating unified response types with http response types.
(-> 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).
(->> 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).
(?-> & forms)
The safe version of the macro ->
(the thread-first
macro).
The safe version of the macro `->` (the `thread-first` macro).
(?->> & forms)
The safe version of the macro ->>
(the thread-last
macro).
The safe version of the macro `->>` (the `thread-last` macro).
(as-accepted data)
(as-accepted data meta)
Returns unified ::accepted
response.
Returns unified `::accepted` response.
(as-busy data)
(as-busy data meta)
Returns unified ::busy
response.
Returns unified `::busy` response.
(as-conflict data)
(as-conflict data meta)
Returns unified ::conflict
response.
Returns unified `::conflict` response.
(as-created data)
(as-created data meta)
Returns unified ::created
response.
Returns unified `::created` response.
(as-deleted data)
(as-deleted data meta)
Returns unified ::deleted
response.
Returns unified `::deleted` response.
(as-error data)
(as-error data meta)
(as-error type data meta)
Returns unified ::error
response.
Returns unified `::error` response.
(as-exception data)
(as-exception data meta)
Returns unified ::exception
response.
Returns unified `::exception` response.
(as-forbidden data)
(as-forbidden data meta)
Returns unified ::forbidden
response.
Returns unified `::forbidden` response.
(as-http x)
Returns ring response by the given unified response type.
Returns ring response by the given unified response type.
(as-incorrect data)
(as-incorrect data meta)
Returns unified ::incorrect
response.
Returns unified `::incorrect` response.
(as-interrupted data)
(as-interrupted data meta)
Returns unified ::interrupted
response.
Returns unified `::interrupted` response.
(as-not-found data)
(as-not-found data meta)
Returns unified ::not-found
response.
Returns unified `::not-found` response.
(as-success data)
(as-success data meta)
(as-success type data meta)
Returns unified ::success
response.
Returns unified `::success` response.
(as-unauthorized data)
(as-unauthorized data meta)
Returns unified ::unauthorized
response.
Returns unified `::unauthorized` response.
(as-unavailable data)
(as-unavailable data meta)
Returns unified ::unavailable
response.
Returns unified `::unavailable` response.
(as-unknown data)
(as-unknown data meta)
Returns unified ::unknown
response.
Returns unified `::unknown` response.
(as-unsupported data)
(as-unsupported data meta)
Returns unified ::unsupported
response.
Returns unified `::unsupported` response.
(as-warning data)
(as-warning data meta)
Returns unified ::warning
response.
Returns unified `::warning` response.
(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`.
(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`.
(-get-meta _)
Returns meta
of response.
Returns `meta` of response.
(-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? _)
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-data _ data)
Sets data
of response.
Sets `data` of response.
(-set-type _ type)
Sets type
of response.
Sets `type` of response.
(-set-meta _ meta)
Sets meta
of response.
Sets `meta` of response.
(-get-type _)
Returns type
of response.
Returns `type` of response.
(-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-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.
(link! unified http & kvs)
Associate unified response type with http response type.
Returns:
true
- when all unified response types successfully linkedParams:
unified
- unified response typehttp
- http response typeThrows:
ExceptionInfo
:
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
(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 responseReturns ring response, where: * `:status` - gets from the registry by the unified response type * `:header` - empty map * `:body` - unwrapped unified response
(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`.
(safe body)
(safe body handler)
Extended version of try-catch.
Extended version of try-catch.
(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`.
(unwrap response)
Returns unwrapped unified response (as map).
Returns unwrapped unified response (as map).
(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`.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close