Refactor commands.
This commit is contained in:
@ -1,16 +1,19 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/coreos/etcd/command"
|
||||
"github.com/coreos/go-raft"
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// The Server provides an HTTP interface to the underlying store.
|
||||
type Server interface {
|
||||
CommitIndex() uint64
|
||||
Term() uint64
|
||||
Dispatch(Command, http.ResponseWriter, *http.Request)
|
||||
CommitIndex() uint64
|
||||
Term() uint64
|
||||
Dispatch(command.Command, http.ResponseWriter, *http.Request)
|
||||
}
|
||||
|
||||
// This is the default implementation of the Server interface.
|
||||
@ -55,11 +58,6 @@ func (s *server) Term() uint64 {
|
||||
return c.raftServer.Term()
|
||||
}
|
||||
|
||||
// Executes a command against the Raft server.
|
||||
func (s *server) Do(c Command, localOnly bool) (interface{}, error) {
|
||||
return c.raftServer.Do(s.RaftServer().Server)
|
||||
}
|
||||
|
||||
func (s *server) installV1() {
|
||||
s.handleFunc("/v1/keys/{key:.*}", v1.GetKeyHandler).Methods("GET")
|
||||
s.handleFunc("/v1/keys/{key:.*}", v1.SetKeyHandler).Methods("POST", "PUT")
|
||||
|
Reference in New Issue
Block a user