1
0
Fork 0

Changed session logic

This commit is contained in:
Alex Myasoedov 2018-01-18 20:01:16 -05:00
parent e72437eff8
commit 4e0b63b38b
No known key found for this signature in database
GPG key ID: D261413C245982F0

23
main.go
View file

@ -13,6 +13,7 @@ import (
haikunator "github.com/atrox/haikunatorgo" haikunator "github.com/atrox/haikunatorgo"
"github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/msoedov/hacker-slides/files"
) )
const sessionHeader = "slide-session" const sessionHeader = "slide-session"
@ -75,15 +76,23 @@ func NewApp() *gin.Engine {
r.GET("/", func(c *gin.Context) { r.GET("/", func(c *gin.Context) {
fname := c.Param("name") latest := files.LatestFileIn("slides")
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"name": fname, "name": latest,
}).Info("Restore?") }).Info("Restoring latest point")
var path string
if latest == "" {
haikunator := haikunator.New()
haikunator.TokenLength = 0
name := haikunator.Haikunate()
path = fmt.Sprintf("slides/%s.md", name)
} else {
name := latest
path = fmt.Sprintf("slides/%s", name)
}
haikunator := haikunator.New()
haikunator.TokenLength = 0
name := haikunator.Haikunate()
path := fmt.Sprintf("slides/%s.md", name)
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"path": path, "path": path,
}).Info("A new session") }).Info("A new session")