github.com/ghodss/etcd@v0.3.1-0.20140417172404-cc329bfa55cb/server/v2/post_handler.go (about) 1 package v2 2 3 import ( 4 "net/http" 5 6 etcdErr "github.com/coreos/etcd/error" 7 "github.com/coreos/etcd/store" 8 "github.com/coreos/etcd/third_party/github.com/gorilla/mux" 9 ) 10 11 func PostHandler(w http.ResponseWriter, req *http.Request, s Server) error { 12 vars := mux.Vars(req) 13 key := "/" + vars["key"] 14 15 value := req.FormValue("value") 16 dir := (req.FormValue("dir") == "true") 17 expireTime, err := store.TTL(req.FormValue("ttl")) 18 if err != nil { 19 return etcdErr.NewError(etcdErr.EcodeTTLNaN, "Create", s.Store().Index()) 20 } 21 22 c := s.Store().CommandFactory().CreateCreateCommand(key, dir, value, expireTime, true) 23 return s.Dispatch(c, w, req) 24 }