1 Star 1 Fork 0

hh/etcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
handler.go 834 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ben Johnson 提交于 2013-12-11 21:40 . mod/leader
package v2
import (
"net/http"
"github.com/gorilla/mux"
)
// prefix is appended to the lock's prefix since the leader mod uses the lock mod.
const prefix = "/_mod/leader"
// handler manages the leader HTTP request.
type handler struct {
*mux.Router
client *http.Client
transport *http.Transport
addr string
}
// NewHandler creates an HTTP handler that can be registered on a router.
func NewHandler(addr string) (http.Handler) {
transport := &http.Transport{DisableKeepAlives: false}
h := &handler{
Router: mux.NewRouter(),
client: &http.Client{Transport: transport},
transport: transport,
addr: addr,
}
h.StrictSlash(false)
h.HandleFunc("/{key:.*}", h.getHandler).Methods("GET")
h.HandleFunc("/{key:.*}", h.setHandler).Methods("PUT")
h.HandleFunc("/{key:.*}", h.deleteHandler).Methods("DELETE")
return h
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/w1229748769/etcd.git
git@gitee.com:w1229748769/etcd.git
w1229748769
etcd
etcd
v0.2.0-rc3

搜索帮助