blob: d6db65dd44ff03b102b25f09d941d6e936e535ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package app
import (
"fmt"
"net/http"
"appengine"
"appengine/memcache"
_ "github.com/mattermost/rsc/appfs/server"
_ "github.com/mattermost/rsc/blog/post"
)
func init() {
http.HandleFunc("/admin/", Admin)
}
func Admin(w http.ResponseWriter, req *http.Request) {
c := appengine.NewContext(req)
switch req.FormValue("op") {
default:
fmt.Fprintf(w, "unknown op %s\n", req.FormValue("op"))
case "memcache-get":
key := req.FormValue("key")
item, err := memcache.Get(c, key)
if err != nil {
fmt.Fprintf(w, "ERROR: %s\n", err)
return
}
w.Write(item.Value)
case "memcache-delete":
key := req.FormValue("key")
if err := memcache.Delete(c, key); err != nil {
fmt.Fprintf(w, "ERROR: %s\n", err)
return
}
fmt.Fprintf(w, "deleted %s\n", key)
}
}
|