再会,
我最近开始使用RingoJS和Stick 中间件,现在我被会话困住了。我不能让它工作。
main.js
var {Application} = require( "./_lib_/stick" ),
app = exports.app = Application();
app.configure( "mount" );
app.mount( "/", require( "./actions" ) );
if ( require.main === module ) {
require( "ringo/httpserver" ).main( module.directory );
}
动作.js
var {Application, helpers} = require( "./_lib_/stick" ),
Response = require( "ringo/jsgi/response" );
export( "app" );
var app = Application();
app.configure( "route", "render", "session" );
app.render.base = module.resolve( "templates" );
app.render.master = "page.html";
app.get("/session.htm", function( request ) {
//request.session.data.foo = "bar";
request.session.data.put("foo", "bar");
return Response.redirect( "session2.htm" );
});
app.get("/session2.htm", function( request ) {
var value = request.session;
return Response.html( "Session: " + value );
});
我已经测试了许多组合,但没有一个像预期的那样工作。
我得到的大多数错误都是关于从会话中读取数据。例如:
TypeError:无法从未定义中读取属性“数据”
有小费吗?