Changed session logic
This commit is contained in:
parent
e72437eff8
commit
4e0b63b38b
1 changed files with 16 additions and 7 deletions
23
main.go
23
main.go
|
@ -13,6 +13,7 @@ import (
|
|||
haikunator "github.com/atrox/haikunatorgo"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/msoedov/hacker-slides/files"
|
||||
)
|
||||
|
||||
const sessionHeader = "slide-session"
|
||||
|
@ -75,15 +76,23 @@ func NewApp() *gin.Engine {
|
|||
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
|
||||
fname := c.Param("name")
|
||||
latest := files.LatestFileIn("slides")
|
||||
log.WithFields(log.Fields{
|
||||
"name": fname,
|
||||
}).Info("Restore?")
|
||||
"name": latest,
|
||||
}).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{
|
||||
"path": path,
|
||||
}).Info("A new session")
|
||||
|
|
Loading…
Reference in a new issue