1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Case doesn't matter

This commit is contained in:
Zack Scholl
2016-02-07 00:50:28 -05:00
parent 467eb4d5b6
commit 46fad8792c

13
main.go
View File

@ -134,12 +134,9 @@ func main() {
}) })
r.GET("/:title", func(c *gin.Context) { r.GET("/:title", func(c *gin.Context) {
title := c.Param("title") title := c.Param("title")
fmt.Println("------")
fmt.Println("[" + c.ClientIP() + "]")
fmt.Println("------")
if title == "ws" { if title == "ws" {
wshandler(c.Writer, c.Request) wshandler(c.Writer, c.Request)
} else if title == "about" && strings.Contains(AllowedIPs, c.ClientIP()) != true { } else if strings.ToLower(title) == "about" && strings.Contains(AllowedIPs, c.ClientIP()) != true {
c.Redirect(302, "/about/view") c.Redirect(302, "/about/view")
} else { } else {
c.HTML(http.StatusOK, "index.tmpl", gin.H{ c.HTML(http.StatusOK, "index.tmpl", gin.H{
@ -149,11 +146,11 @@ func main() {
} }
}) })
r.GET("/:title/*option", func(c *gin.Context) { r.GET("/:title/*option", func(c *gin.Context) {
title := c.Param("title")
option := c.Param("option") option := c.Param("option")
title := c.Param("title")
fmt.Println(title, "["+option+"]") fmt.Println(title, "["+option+"]")
if option == "/view" { if option == "/view" {
p := CowyoData{title, ""} p := CowyoData{strings.ToLower(title), ""}
err := p.load() err := p.load()
if err != nil { if err != nil {
panic(err) panic(err)
@ -206,14 +203,14 @@ func wshandler(w http.ResponseWriter, r *http.Request) {
} }
if m.UpdateServer { if m.UpdateServer {
p := CowyoData{m.Title, m.TextData} p := CowyoData{strings.ToLower(m.Title), m.TextData}
err := p.save() err := p.save()
if err != nil { if err != nil {
panic(err) panic(err)
} }
} }
if m.UpdateClient { if m.UpdateClient {
p := CowyoData{m.Title, ""} p := CowyoData{strings.ToLower(m.Title), ""}
err := p.load() err := p.load()
if err != nil { if err != nil {
panic(err) panic(err)