Fix: typo

This commit is contained in:
Dreamacro
2018-07-18 21:50:16 +08:00
parent d55e1b664b
commit d540a0d29f
7 changed files with 63 additions and 63 deletions

View File

@ -13,7 +13,7 @@ import (
func proxyRouter() http.Handler {
r := chi.NewRouter()
r.Get("/", getProxys)
r.Get("/", getProxies)
r.Get("/{name}", getProxy)
r.Put("/{name}", updateProxy)
return r
@ -56,23 +56,23 @@ func transformProxy(proxy C.Proxy) interface{} {
}
}
type GetProxysResponse struct {
Proxys map[string]interface{} `json:"proxys"`
type GetProxiesResponse struct {
Proxies map[string]interface{} `json:"proxies"`
}
func getProxys(w http.ResponseWriter, r *http.Request) {
_, rawProxys := tunnel.Config()
proxys := make(map[string]interface{})
for name, proxy := range rawProxys {
proxys[name] = transformProxy(proxy)
func getProxies(w http.ResponseWriter, r *http.Request) {
_, rawProxies := tunnel.Config()
proxies := make(map[string]interface{})
for name, proxy := range rawProxies {
proxies[name] = transformProxy(proxy)
}
render.JSON(w, r, GetProxysResponse{Proxys: proxys})
render.JSON(w, r, GetProxiesResponse{Proxies: proxies})
}
func getProxy(w http.ResponseWriter, r *http.Request) {
name := chi.URLParam(r, "name")
_, proxys := tunnel.Config()
proxy, exist := proxys[name]
_, proxies := tunnel.Config()
proxy, exist := proxies[name]
if !exist {
w.WriteHeader(http.StatusNotFound)
render.JSON(w, r, Error{
@ -98,8 +98,8 @@ func updateProxy(w http.ResponseWriter, r *http.Request) {
}
name := chi.URLParam(r, "name")
_, proxys := tunnel.Config()
proxy, exist := proxys[name]
_, proxies := tunnel.Config()
proxy, exist := proxies[name]
if !exist {
w.WriteHeader(http.StatusNotFound)
render.JSON(w, r, Error{

View File

@ -23,7 +23,7 @@ func NewHub(addr string) {
r.Get("/traffic", traffic)
r.Get("/logs", getLogs)
r.Mount("/configs", configRouter())
r.Mount("/proxys", proxyRouter())
r.Mount("/proxies", proxyRouter())
r.Mount("/rules", ruleRouter())
err := http.ListenAndServe(addr, r)