Add Path function
This commit is contained in:
parent
d844211d22
commit
0a5d7931e4
1 changed files with 7 additions and 3 deletions
10
main.go
10
main.go
|
@ -63,6 +63,10 @@ func authorizationHeader(user, password string) string {
|
||||||
return "Basic " + base64.StdEncoding.EncodeToString([]byte(base))
|
return "Basic " + base64.StdEncoding.EncodeToString([]byte(base))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SlidePath(name string) string {
|
||||||
|
return fmt.Sprintf("slides/%s.md", name)
|
||||||
|
}
|
||||||
|
|
||||||
func NewApp() *gin.Engine {
|
func NewApp() *gin.Engine {
|
||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
@ -90,7 +94,7 @@ func NewApp() *gin.Engine {
|
||||||
} else {
|
} else {
|
||||||
name = strings.Replace(latest, ".md", "", 1)
|
name = strings.Replace(latest, ".md", "", 1)
|
||||||
}
|
}
|
||||||
path = fmt.Sprintf("slides/%s.md", name)
|
path = SlidePath(name)
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"path": path,
|
"path": path,
|
||||||
|
@ -185,7 +189,7 @@ func NewApp() *gin.Engine {
|
||||||
if strings.HasSuffix(name, ".md") {
|
if strings.HasSuffix(name, ".md") {
|
||||||
name = name[0 : len(name)-3]
|
name = name[0 : len(name)-3]
|
||||||
}
|
}
|
||||||
path := fmt.Sprintf("slides/%s.md", name)
|
path := SlidePath(name)
|
||||||
session := sessions.Default(c)
|
session := sessions.Default(c)
|
||||||
session.Set("name", path)
|
session.Set("name", path)
|
||||||
session.Save()
|
session.Save()
|
||||||
|
@ -205,7 +209,7 @@ func NewApp() *gin.Engine {
|
||||||
if strings.HasSuffix(name, ".md") {
|
if strings.HasSuffix(name, ".md") {
|
||||||
name = name[0 : len(name)-3]
|
name = name[0 : len(name)-3]
|
||||||
}
|
}
|
||||||
path := fmt.Sprintf("slides/%s.md", name)
|
path := SlidePath(name)
|
||||||
session := sessions.Default(c)
|
session := sessions.Default(c)
|
||||||
session.Set("name", path)
|
session.Set("name", path)
|
||||||
session.Save()
|
session.Save()
|
||||||
|
|
Loading…
Reference in a new issue