mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Case doesn't matter
Former-commit-id: 45ffdaab7656f34a3bbdd6385d8a9eb10cd20625 [formerly 8c04f71d6c305ab95eff3ce46abe70dbd2e346ab] [formerly 3f83e3e27fccc29393d8941746e6310b404022a1 [formerly 32f4f9d043e804c9ece1eb9931795e7817eee4f1 [formerly46fad8792c
]]] Former-commit-id: ecb994f5750f7393d4989abb0b88fac4eb73dfcb [formerly de5935a8cae7f35878bff81d50ae28cf59f9b9c0] Former-commit-id: 4a3184caf2004e544876ff11d6d0bf4e844817e1 Former-commit-id:76ea57885f
This commit is contained in:
parent
fe8dfe55bc
commit
aa38afccef
13
main.go
13
main.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user