/// <summary>
        /// Loads the request session
        /// </summary>
        /// <param name="context">Nancy context</param>
        /// <param name="sessionStore">Session store</param>
        /// <returns>Always returns null</returns>
        private static Nancy.Response LoadSession(NancyContext context, RethinkDbSessions sessionStore)
        {
            if (context.Request == null)
            {
                return(null);
            }

            context.Request.Session = sessionStore.Load(context.Request);

            return(null);
        }
        /// <summary>
        /// Initialise and add RethinkDB session storage hooks to the application pipeline
        /// </summary>
        /// <param name="pipelines">Application pipelines</param>
        /// <param name="configuration">Cookie based sessions configuration.</param>
        public static void Enable(IPipelines pipelines, RethinkDbSessionConfiguration configuration)
        {
            if (pipelines == null)
            {
                throw new ArgumentNullException("pipelines");
            }

            var sessionStore = new RethinkDbSessions(configuration);

            pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx => LoadSession(ctx, sessionStore));
            pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => SaveSession(ctx, sessionStore));
        }
 /// <summary>
 /// Saves the request session into the response
 /// </summary>
 /// <param name="context">Nancy context</param>
 /// <param name="sessionStore">Session store</param>
 private static void SaveSession(NancyContext context, RethinkDbSessions sessionStore)
 {
     sessionStore.Save(context.Request.Session, context.Response);
 }