Compare commits
2 Commits
00781c0019
...
b342eef1ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
b342eef1ef
|
|||
|
a001b4c8da
|
26
main.go
26
main.go
@@ -139,6 +139,32 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("500 Internal Server Error"))
|
||||
}
|
||||
}
|
||||
|
||||
if command == "list" {
|
||||
ctx := context.Background()
|
||||
keys, err := client.Keys(ctx, "*").Result()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte("500 Internal Server Error"))
|
||||
return
|
||||
}
|
||||
|
||||
resp := ""
|
||||
for _, key := range keys {
|
||||
value, err = client.Get(ctx, key).Result()
|
||||
if err == redis.Nil {
|
||||
w.WriteHeader(500)
|
||||
w.Write([]byte("500 Internal Server Error"))
|
||||
return
|
||||
}
|
||||
resp += key + ":" + value + "\n"
|
||||
}
|
||||
|
||||
w.WriteHeader(200)
|
||||
w.Write([]byte(resp))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func shortlinkHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -13,7 +13,7 @@ sus URL shortener
|
||||
|
||||
susmng [-s pls.cx] delete -l shortlink -v confirm
|
||||
|
||||
`susmng` will assume the first server in the `secrets` section of the configuration file if the -s
|
||||
`susmng` will assume the first server in the `secrets` section of the configuration file if the `-s`
|
||||
flag is not provided.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user