From 008e13fba55964a3f10f456413148189e258d219 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Fri, 12 Aug 2022 08:08:11 -0700 Subject: [PATCH] Get session cookie. --- examples/todos/app/Route/Index.elm | 46 +++++++++++++++++++----------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/examples/todos/app/Route/Index.elm b/examples/todos/app/Route/Index.elm index f44112c6..da4b13f8 100644 --- a/examples/todos/app/Route/Index.elm +++ b/examples/todos/app/Route/Index.elm @@ -12,6 +12,7 @@ import Html exposing (..) import Html.Attributes exposing (..) import Html.Keyed as Keyed import Html.Lazy exposing (lazy, lazy2) +import MySession import Pages.Msg import Pages.PageUrl exposing (PageUrl) import Path exposing (Path) @@ -19,6 +20,7 @@ import RouteBuilder exposing (StatefulRoute, StatelessRoute, StaticPayload) import Seo.Common import Server.Request as Request import Server.Response as Response exposing (Response) +import Server.Session as Session exposing (Session) import Shared import View exposing (View) @@ -105,23 +107,33 @@ head static = data : RouteParams -> Request.Parser (DataSource (Response Data ErrorPage)) data routeParams = - Request.succeed - (DataSource.succeed - (Response.render - { entries = - [ { description = "Test" - , completed = False - , editing = False - , id = 1 - } - , { description = "Test 2" - , completed = False - , editing = False - , id = 2 - } - ] - } - ) + MySession.withSession + (Request.succeed ()) + (\() session -> + let + okSessionThing : Session + okSessionThing = + session + |> Result.withDefault Nothing + |> Maybe.withDefault Session.empty + in + DataSource.succeed + ( okSessionThing + , Response.render + { entries = + [ { description = "Test" + , completed = False + , editing = False + , id = 1 + } + , { description = "Test 2" + , completed = False + , editing = False + , id = 2 + } + ] + } + ) )