如何从clojure liberator中的post子句返回401代码?

如何从clojure liberator中的post子句返回401代码?,clojure,liberator,Clojure,Liberator,我有这样一个密码: (defresource errors [] :authorized? (fn [ctx] (authorized? ctx)) :allowed-methods [:post :options] :available-media-types media-types :post! (fn [ctx] (-> ctx pa

我有这样一个密码:

(defresource errors []
         :authorized? (fn [ctx] (authorized? ctx))
         :allowed-methods [:post :options]
         :available-media-types media-types
         :post!      (fn [ctx] (-> ctx
                                   parse-json
                                   errors/insert-error)))

授权?函数检查用户令牌,但我有一些其他规则,我想在帖子里面检查!功能。怎么做?我可以从帖子中抛出一个异常!函数,但我想返回401状态代码。

您的问题不清楚您想在
:post中检查什么功能,但在正常情况下,
:post函数不会返回401错误

如果您想返回401,那么您可能应该在
:authorized?
函数中检查请求,并从中返回true或false

如果你能详细说明你想要检查的规则,那么我的答案可能会更具体


您可能已经这样做了,但请确保您理解了,以及您的请求是如何通过的。

我决定使用allowed?检查特定用户是否可以发布数据。