add delete handler

release-0.4
Xiang Li 2013-06-09 11:12:32 -07:00
parent 69a8116272
commit 4ff786b4a2
2 changed files with 13 additions and 1 deletions

View File

@ -118,6 +118,18 @@ func GetHttpHandler(w http.ResponseWriter, req *http.Request) {
}
func DeleteHttpHandler(w http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
debug("[recv] GET http://%v/delete/%s", server.Name(), vars["key"])
command := &DeleteCommand{}
command.Key = vars["key"]
Dispatch(server, command, w)
}
func Dispatch(server *raft.Server, command Command, w http.ResponseWriter) {
var body []byte

View File

@ -130,7 +130,7 @@ func main() {
// external commands
r.HandleFunc("/set/{key}", SetHttpHandler).Methods("POST")
r.HandleFunc("/get/{key}", GetHttpHandler).Methods("GET")
//r.HandleFunc("/delete/{key}", DeleteHttpHandler).Methods("GET")
r.HandleFunc("/delete/{key}", DeleteHttpHandler).Methods("GET")
http.Handle("/", r)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", info.Port), nil))