DelHandler 支持http进行Delete
(w http.ResponseWriter, r *http.Request)
| 49 | |
| 50 | // DelHandler 支持http进行Delete |
| 51 | func (hs *HttpHandler) DelHandler(w http.ResponseWriter, r *http.Request) { |
| 52 | key := r.FormValue("key") |
| 53 | if key == "" { |
| 54 | http.Error(w, "key is empty", http.StatusBadRequest) |
| 55 | return |
| 56 | } |
| 57 | err := hs.Delete([]byte(key)) |
| 58 | if err != nil { |
| 59 | http.Error(w, err.Error(), http.StatusInternalServerError) |
| 60 | return |
| 61 | } |
| 62 | _, err = w.Write([]byte("ok")) |
| 63 | if err != nil { |
| 64 | return |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // GetHandler 支持http进行Get |
| 69 | func (hs *HttpHandler) GetHandler(w http.ResponseWriter, r *http.Request) { |