1 module hunt.http.routing.handler.LocalHttpSessionHandler; 2 3 import hunt.http.routing.RoutingContext; 4 import hunt.http.routing.impl.HttpSessionHandlerImpl; 5 import hunt.http.routing.impl.RoutingContextImpl; 6 7 import hunt.http.server.HttpServerOptions; 8 import hunt.http.server.HttpSession; 9 import hunt.http.server.LocalSessionStore; 10 11 import hunt.util.AbstractLifecycle; 12 13 /** 14 * 15 */ 16 class LocalHttpSessionHandler : AbstractLifecycle, RouteHandler { 17 18 private SessionStore sessionStore; 19 private HttpServerOptions _options; 20 21 // this() { 22 // this(new HttpSessionConfiguration()); 23 // sessionStore = new LocalSessionStore(); 24 // } 25 26 this(HttpServerOptions options) { 27 _options = options; 28 sessionStore = new LocalSessionStore(); 29 start(); 30 } 31 32 override 33 void handle(RoutingContext context) { 34 RoutingContextImpl ctx = cast(RoutingContextImpl) context; 35 HttpSessionHandlerImpl sessionHandler = new HttpSessionHandlerImpl(context, sessionStore, 36 _options.getSessionIdParameterName(), _options.getDefaultMaxInactiveInterval()); 37 ctx.setHttpSessionHandler(sessionHandler); 38 context.next(); 39 } 40 41 SessionStore getSessionStore() { 42 return sessionStore; 43 } 44 45 // HttpServerOptions getConfiguration() { 46 // return configuration; 47 // } 48 49 override 50 protected void initialize() { 51 52 } 53 54 override 55 protected void destroy() { 56 sessionStore.stop(); 57 } 58 }