如何在Compojure中使用lib-noir状态会话 [英] Howto use lib-noir stateful-sessions in Compojure

查看:159
本文介绍了如何在Compojure中使用lib-noir状态会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我在这里有一个相当简单的问题。但我一直在看这个屏幕太长。所以我试图(和失败)获得有状态会话在Compojure工作。 refheap代码粘贴 在这里

I think I have a fairly straightforward problem here. But I've been looking at this screen too long. So I'm trying (and failing) to get stateful sessions working in Compojure. The refheap code paste is here.

您可以看到我试图使用 lib-noir (第62行)初始化状态会话。然后,当应用程式正在执行时,我尝试拨打 工作阶段/ put! 会话中的一些数据(第43行)。

You can see me trying to use lib-noir (line 62) to initialize stateful sessions. Then when the app is running, I try to make a call to session/put! some data in the session (line 43).

现在,这个stacktrace说,在session.put!中,lib-noir试图交换一个尚未绑定的会话var。现在,我想我在线62上。所以我相信这是一个简单的修复,另一组眼睛会看到。

Now, this stacktrace says that in session.put!, lib-noir is trying to swap out a session var that hasn't been bound. Now, I thought I did that on line 62. So I'm sure this is a simple fix that another set of eyes will see.

java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Atom                                                                                                                                                                                                                                                                                                                                
        at clojure.core$swap_BANG_.invoke(core.clj:2110)                                                                                                                                                                                                                                                                                                                                                                  
        at noir.session$put_BANG_.invoke(session.clj:18)                                                                                                                                                                                                                                                                                                                                                                  
        at bkell.http.handler$fn__6159.invoke(handler.clj:156)                                                                                                                                                                                                                                                                                                                                                            
        at compojure.core$make_route$fn__3800.invoke(core.clj:93)                                                                                                                                                                                                                                                                                                                                                         
        at compojure.core$if_route$fn__3784.invoke(core.clj:39)                                                                                                                                                                                                                                                                                                                                                           
        at compojure.core$if_method$fn__3777.invoke(core.clj:24)                                                                                                                                                                                                                                                                                                                                                          
        at compojure.core$routing$fn__3806.invoke(core.clj:106)                                                                                                                                                                                                                                                                                                                                                           
        at clojure.core$some.invoke(core.clj:2390)                                                                                                                                                                                                                                                                                                                                                                        
        at compojure.core$routing.doInvoke(core.clj:106)                                                                                                                                                                                                                                                                                                                                                                  
        at clojure.lang.RestFn.applyTo(RestFn.java:139)                                                                                                                                                                                                                                                                                                                                                                   
        ...
        at java.lang.Thread.run(Thread.java:619)

感谢

推荐答案

由James Reeves在 - https:// groups回答。 google.com/forum/#!topic/compojure/yG6nCXiEinU

Answered by James Reeves at - https://groups.google.com/forum/#!topic/compojure/yG6nCXiEinU


尝试在处理程序/网站和换行noir-会话*。因为
处理程序/网站应用wrap-session中间件,
wrap-noir-session *取决于根据文档,
处理程序/网站应该在wrap-noir-session之前应用

Try swapping around handler/site and wrap-noir-session*. Because handler/site applies the wrap-session middleware, and wrap-noir-session* depends on that according to the documentation, handler/site should be applied before wrap-noir-session.


  • James

这篇关于如何在Compojure中使用lib-noir状态会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆