Skip to content

Commit

Permalink
add delete handler
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Jun 9, 2013
1 parent 69a8116 commit 4ff786b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion raftd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4ff786b

Please sign in to comment.