Liberator Custom Not Authorized Message

48 views Asked by At

How do I pass in a custom 401 Not Authorized message when :not-authorized? is true? I'd like to show a more useful message like Key must have admin permissions.

1

There are 1 answers

0
Piotrek Bzdyl On

You need to take a look at handlers:

For every http status code there is a handler function defined in liberator. All have sensible defaults and will return a simple english error message or an empty response, whatever is appropriate.

In your case you need to provide your own handler for :handle-unauthorized key:

(defresource my-resource
  ...
  :handle-unauthorized (fn [ctx] ...))