mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

for i in github.com/BurntSushi/toml github.com/coreos/go-etcd/etcd github.com/coreos/go-log/log github.com/gorilla/context github.com/rcrowley/go-metrics bitbucket.org/kardianos/osext github.com/coreos/go-systemd/journal github.com/coreos/raft code.google.com/p/goprotobuf/proto ; do goven -copy -rewrite $i; done
25 lines
640 B
Go
25 lines
640 B
Go
package v2
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
etcdErr "github.com/coreos/etcd/error"
|
|
"github.com/coreos/etcd/store"
|
|
"github.com/coreos/etcd/third_party/github.com/gorilla/mux"
|
|
)
|
|
|
|
func PostHandler(w http.ResponseWriter, req *http.Request, s Server) error {
|
|
vars := mux.Vars(req)
|
|
key := "/" + vars["key"]
|
|
|
|
value := req.FormValue("value")
|
|
dir := (req.FormValue("dir") == "true")
|
|
expireTime, err := store.TTL(req.FormValue("ttl"))
|
|
if err != nil {
|
|
return etcdErr.NewError(etcdErr.EcodeTTLNaN, "Create", s.Store().Index())
|
|
}
|
|
|
|
c := s.Store().CommandFactory().CreateCreateCommand(key, dir, value, expireTime, true)
|
|
return s.Dispatch(c, w, req)
|
|
}
|