Collection of useful interceptors
Collection of useful interceptors
On enter: validates request parameters On leave: validates response body on request error: responds {:status 400, :body "Request coercion failed"} on response error: responds {:status 400, :body "Response validation failed"}
On enter: validates request parameters On leave: validates response body on request error: responds {:status 400, :body "Request coercion failed"} on response error: responds {:status 400, :body "Response validation failed"}
Log interceptor. Enter: Print 'Enter:' followed by the complete state map. Leave: Print 'Leave:' followed by the complete state map.
Log interceptor. Enter: Print 'Enter:' followed by the complete state map. Leave: Print 'Leave:' followed by the complete state map.
(message msg)
This interceptor creates a function that prints predefined message. Enter: Print an arbitrary message. Leave: Print an arbitrary message.
This interceptor creates a function that prints predefined message. Enter: Print an arbitrary message. Leave: Print an arbitrary message.
(muuntaja)
(muuntaja interceptor)
Muuntaja encoder/decoder interceptor.
Muuntaja encoder/decoder interceptor.
Update the request map with parsed url-encoded parameters. Adds the following keys to the request map:
:query-params - a map of parameters from the query string :form-params - a map of parameters from the body :params - a merged map of all types of parameter
Enter: TODO. Leave: nil.
Update the request map with parsed url-encoded parameters. Adds the following keys to the request map: :query-params - a map of parameters from the query string :form-params - a map of parameters from the body :params - a merged map of all types of parameter Enter: TODO. Leave: nil.
This interceptor removes bodies from GET requests on Enter.
This interceptor removes bodies from GET requests on Enter.
(session-user-id)
This interceptor handles the session user id management. Enter: Get the session id from the request header, if that operation doesn't succeed a new session is created an associated to the current state, otherwise the cached session data is used. Leave: Verify if the state has a session id, if so add it to the session instance and remove the new session property of the current state. The final step is the association of the session id to the response header.
This interceptor handles the session user id management. Enter: Get the session id from the request header, if that operation doesn't succeed a new session is created an associated to the current state, otherwise the cached session data is used. Leave: Verify if the state has a session id, if so add it to the session instance and remove the new session property of the current state. The final step is the association of the session id to the response header.
(session-user-role)
(session-user-role f role)
This interceptor updates session data user role:authorization from the given request header. Enter: Fetch the authorization from its request/state if succeeds update the current state with that information, also update the user role with a custom value or the default :guest. Leave: nil.
This interceptor updates session data user role:authorization from the given request header. Enter: Fetch the authorization from its request/state if succeeds update the current state with that information, also update the user role with a custom value or the default :guest. Leave: nil.
Side-effect interceptor.
Enter: nil.
Leave: apply :side-effect
state key to state if it exists.
Side-effect interceptor. Enter: nil. Leave: apply `:side-effect` state key to state if it exists.
View interceptor.
Enter: nil. Leave: apply :view
state key to state if it exists and
:response
is absent.
View interceptor. Enter: nil. Leave: apply `:view` state key to state if it exists and `:response` is absent.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close