mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add delete handler
This commit is contained in:
parent
69a8116272
commit
4ff786b4a2
12
handlers.go
12
handlers.go
@ -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
|
||||
|
2
raftd.go
2
raftd.go
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user