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 46fad8792c
]]
Former-commit-id: ecb994f5750f7393d4989abb0b88fac4eb73dfcb [formerly de5935a8cae7f35878bff81d50ae28cf59f9b9c0]
Former-commit-id: 4a3184caf2004e544876ff11d6d0bf4e844817e1
This commit is contained in:
parent
d55bc9e0f9
commit
76ea57885f
13
main.go
13
main.go
@ -134,12 +134,9 @@ func main() {
|
||||
})
|
||||
r.GET("/:title", func(c *gin.Context) {
|
||||
title := c.Param("title")
|
||||
fmt.Println("------")
|
||||
fmt.Println("[" + c.ClientIP() + "]")
|
||||
fmt.Println("------")
|
||||
if title == "ws" {
|
||||
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")
|
||||
} else {
|
||||
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||
@ -149,11 +146,11 @@ func main() {
|
||||
}
|
||||
})
|
||||
r.GET("/:title/*option", func(c *gin.Context) {
|
||||
title := c.Param("title")
|
||||
option := c.Param("option")
|
||||
title := c.Param("title")
|
||||
fmt.Println(title, "["+option+"]")
|
||||
if option == "/view" {
|
||||
p := CowyoData{title, ""}
|
||||
p := CowyoData{strings.ToLower(title), ""}
|
||||
err := p.load()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -206,14 +203,14 @@ func wshandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if m.UpdateServer {
|
||||
p := CowyoData{m.Title, m.TextData}
|
||||
p := CowyoData{strings.ToLower(m.Title), m.TextData}
|
||||
err := p.save()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if m.UpdateClient {
|
||||
p := CowyoData{m.Title, ""}
|
||||
p := CowyoData{strings.ToLower(m.Title), ""}
|
||||
err := p.load()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Loading…
Reference in New Issue
Block a user