Liking cljdoc? Tell your friends :D

ninja.unifier.response

A Clojure(Script) library for unified responses.

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

*default-error-http-status*clj/s

Default http status for unified error response.

Default http status for unified error response.
sourceraw docstring

*default-http-response*clj/s

Default http response.

Default http response.
sourceraw docstring

*default-http-statuses*clj/s

Map of unified response types associated with http statuses.

Map of unified response types associated with http statuses.
sourceraw docstring

*default-success-http-status*clj/s

Default http status for unified success response.

Default http status for unified success response.
sourceraw docstring

as-acceptedclj/s

(as-accepted x)
(as-accepted x meta)

Returns unified accepted response.

Returns unified accepted response.
sourceraw docstring

as-busyclj/s

(as-busy x)
(as-busy x meta)

Returns unified busy response.

Returns unified busy response.
sourceraw docstring

as-conflictclj/s

(as-conflict x)
(as-conflict x meta)

Returns unified conflict response.

Returns unified conflict response.
sourceraw docstring

as-createdclj/s

(as-created x)
(as-created x meta)

Returns unified created response.

Returns unified created response.
sourceraw docstring

as-deletedclj/s

(as-deleted x)
(as-deleted x meta)

Returns unified deleted response.

Returns unified deleted response.
sourceraw docstring

as-errorclj/s

(as-error x)
(as-error x meta)

Returns unified error response.

Returns unified error response.
sourceraw docstring

as-exceptionclj/s

(as-exception x)
(as-exception x meta)

Returns unified exception response.

Returns unified exception response.
sourceraw docstring

as-forbiddenclj/s

(as-forbidden x)
(as-forbidden x meta)

Returns unified forbidden response.

Returns unified forbidden response.
sourceraw docstring

as-httpclj/s

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

as-incorrectclj/s

(as-incorrect x)
(as-incorrect x meta)

Returns unified incorrect response.

Returns unified incorrect response.
sourceraw docstring

as-interruptedclj/s

(as-interrupted x)
(as-interrupted x meta)

Returns unified interrupted response.

Returns unified interrupted response.
sourceraw docstring

as-mapclj/s

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

as-not-foundclj/s

(as-not-found x)
(as-not-found x meta)

Returns unified not-found response.

Returns unified not-found response.
sourceraw docstring

as-responseclj/s

(as-response x {:keys [error? type meta]})

Returns unified response.

Returns unified response.
sourceraw docstring

as-successclj/s

(as-success x)
(as-success x meta)

Returns unified success response.

Returns unified success response.
sourceraw docstring

as-unauthorizedclj/s

(as-unauthorized x)
(as-unauthorized x meta)

Returns unified unauthorized response.

Returns unified unauthorized response.
sourceraw docstring

as-unavailableclj/s

(as-unavailable x)
(as-unavailable x meta)

Returns unified unavailable response.

Returns unified unavailable response.
sourceraw docstring

as-unknownclj/s

(as-unknown x)
(as-unknown x meta)

Returns unified unknown response.

Returns unified unknown response.
sourceraw docstring

as-unsupportedclj/s

(as-unsupported x)
(as-unsupported x meta)

Returns unified unsupported response.

Returns unified unsupported response.
sourceraw docstring

as-warningclj/s

(as-warning x)
(as-warning x meta)

Returns unified warning response.

Returns unified warning response.
sourceraw 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`.
sourceraw docstring

error?clj/s

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

metaclj/s

(meta x)

Returns meta of unified response. Otherwise nil.

Returns `meta` of unified response. Otherwise `nil`.
sourceraw docstring

not-error->clj/smacro

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

not-error->>clj/smacro

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

response?clj/s

(response? x)

Returns true if the given value is unified response. Otherwise false.

Returns `true` if the given value is unified response. Otherwise `false`.
sourceraw docstring

to-httpclj/s

(to-http x)
(to-http x overrides)

Converts unified response to the http response.

Converts unified response to the http response.
sourceraw docstring

to-mapclj/s

(to-map x)

Converts unified response to the map.

Converts unified response to the map.
sourceraw docstring

try-orclj/smacro

(try-or body)
(try-or body else)

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

typeclj/s

(type x)

Returns type of unified response. Otherwise nil.

Returns `type` of unified response. Otherwise `nil`.
sourceraw docstring

type->http-statusclj/s

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

UnifiedResponseclj/sprotocol

UnifiedResponse protocol.

UnifiedResponse protocol.

-as-httpclj/s

(-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-mapclj/s

(-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?clj/s

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

-metaclj/s

(-meta this)

Returns meta of unified response.

Returns `meta` of unified response.

-response?clj/s

(-response? this)

Returns true if the given value is unified response. Otherwise false.

Returns `true` if the given value is unified response. Otherwise `false`.

-typeclj/s

(-type this)

Returns type of unified response.

Returns `type` of unified response.
sourceraw docstring

with-default-http-error-statusclj/smacro

(with-default-http-error-status default & body)

Overrides the default error http status.

Overrides the default error http status.
sourceraw docstring

with-default-http-responseclj/smacro

(with-default-http-response default & body)

Overrides the default http response.

Overrides the default http response.
sourceraw docstring

with-default-http-statusesclj/smacro

(with-default-http-statuses default & body)

Overrides the default http statuses.

Overrides the default http statuses.
sourceraw docstring

with-default-success-http-statusclj/smacro

(with-default-success-http-status default & body)

Overrides the default success http status.

Overrides the default success http status.
sourceraw docstring

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

× close