A Clojure(Script) library for unified responses.
A Clojure(Script) library for unified responses.
Default http status for unified error response.
Default http status for unified error response.
Map of unified response types associated with http statuses.
Map of unified response types associated with http statuses.
Default http status for unified success response.
Default http status for unified success response.
(as-accepted x)
(as-accepted x meta)
Returns unified accepted response.
Returns unified accepted response.
(as-busy x)
(as-busy x meta)
Returns unified busy response.
Returns unified busy response.
(as-conflict x)
(as-conflict x meta)
Returns unified conflict response.
Returns unified conflict response.
(as-created x)
(as-created x meta)
Returns unified created response.
Returns unified created response.
(as-deleted x)
(as-deleted x meta)
Returns unified deleted response.
Returns unified deleted response.
(as-error x)
(as-error x meta)
Returns unified error response.
Returns unified error response.
(as-exception x)
(as-exception x meta)
Returns unified exception response.
Returns unified exception response.
(as-forbidden x)
(as-forbidden x meta)
Returns unified forbidden response.
Returns unified forbidden response.
(as-http x)
(as-http x overrides)
Returns a unified response as http response. If the given value is not unified response returns nil
.
Returns a unified response as http response. If the given value is not unified response returns `nil`.
(as-incorrect x)
(as-incorrect x meta)
Returns unified incorrect response.
Returns unified incorrect response.
(as-interrupted x)
(as-interrupted x meta)
Returns unified interrupted response.
Returns unified interrupted response.
(as-map x)
Returns a unified response as a map. If the given value is not unified response returns nil
.
Returns a unified response as a map. If the given value is not unified response returns `nil`.
(as-not-found x)
(as-not-found x meta)
Returns unified not-found response.
Returns unified not-found response.
(as-response x {:keys [error? type meta]})
Returns unified response.
Returns unified response.
(as-success x)
(as-success x meta)
Returns unified success response.
Returns unified success response.
(as-unauthorized x)
(as-unauthorized x meta)
Returns unified unauthorized response.
Returns unified unauthorized response.
(as-unavailable x)
(as-unavailable x meta)
Returns unified unavailable response.
Returns unified unavailable response.
(as-unknown x)
(as-unknown x meta)
Returns unified unknown response.
Returns unified unknown response.
(as-unsupported x)
(as-unsupported x meta)
Returns unified unsupported response.
Returns unified unsupported response.
(as-warning x)
(as-warning x 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 unified error response. Otherwise false
.
Returns `true` if the given value is unified error response. Otherwise `false`.
(meta x)
Returns meta
of unified response. Otherwise nil
.
Returns `meta` of unified response. Otherwise `nil`.
(not-error-> expr & forms)
This macro is the same as clojure.core/some->
, but the check is done
using the predicate error?
of the UnifiedResponse
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 `UnifiedResponse` protocol and the substitution occurs as in macro `->` (the `thread-first` macro).
(not-error->> expr & forms)
This macro is the same as clojure.core/some->>
, but the check is done
using the predicate error?
of the UnifiedResponse
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 `UnifiedResponse` protocol and the substitution occurs as in macro `->>` (the `thread-last` macro).
(response? x)
Returns true
if the given value is unified response. Otherwise false
.
Returns `true` if the given value is unified response. Otherwise `false`.
(to-http x)
(to-http x overrides)
Converts unified response to the http response.
Converts unified response to the http response.
(to-map x)
Converts unified response to the map.
Converts unified response to the map.
(try-or body)
(try-or body else)
Extended version of try-catch. Usage:
Extended version of try-catch. Usage: * (try-or (/ 1 0)) ;; => nil * (try-or (/ 1 0) false) ;; => false * (try-or (/ 1 0) #(prn (.getMessage %))) ;; => "Divide by zero"
(type x)
Returns type
of unified response. Otherwise nil
.
Returns `type` of unified response. Otherwise `nil`.
(type->http-status type error?)
Returns http status by the given unified response type.
If type is not registered and error?
is truthy returns *default-error-http-status*
.
Otherwise *default-success-http-status*
.
Returns http status by the given unified response type. If type is not registered and `error?` is truthy returns `*default-error-http-status*`. Otherwise `*default-success-http-status*`.
UnifiedResponse protocol.
UnifiedResponse protocol.
(-as-http this)
(-as-http this overrides)
Returns a unified response as http response or nil
if the given value is not a unified response.
Returns a unified response as http response or `nil` if the given value is not a unified response.
(-as-map this)
Returns a unified response as a map or nil
if the given value is not a unified response.
Returns a unified response as a map or `nil` if the given value is not a unified response.
(-error? this)
Returns true
if the given value is unified error response. Otherwise false
.
Returns `true` if the given value is unified error response. Otherwise `false`.
(-meta this)
Returns meta
of unified response.
Returns `meta` of unified response.
(-response? this)
Returns true
if the given value is unified response. Otherwise false
.
Returns `true` if the given value is unified response. Otherwise `false`.
(-type this)
Returns type
of unified response.
Returns `type` of unified response.
(with-default-http-error-status default & body)
Overrides the default error http status.
Overrides the default error http status.
(with-default-http-response default & body)
Overrides the default http response.
Overrides the default http response.
(with-default-http-statuses default & body)
Overrides the default http statuses.
Overrides the default http statuses.
(with-default-success-http-status default & body)
Overrides the default success http status.
Overrides the default success http status.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close