支持子地址

This commit is contained in:
duanhf2012
2020-01-02 15:30:45 +08:00
parent 7f7bd39dd5
commit 04d3be6fe0

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"reflect" "reflect"
"runtime" "runtime"
@@ -34,6 +35,7 @@ type HttpRequest struct {
ParamStr string ParamStr string
mapParam map[string]string mapParam map[string]string
URL string
//Req http.Request //Req http.Request
} }
@@ -214,11 +216,11 @@ func (slf *ServeHTTPRouterMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
// 拼接得到rpc服务的名称 // 拼接得到rpc服务的名称
vstr := strings.Split(url, "/") vstr := strings.Split(url, "/")
if len(vstr) != 3 { if len(vstr) < 2 {
writeRespone(w, http.StatusNotFound, "Cannot find path.") writeRespone(w, http.StatusNotFound, "Cannot find path.")
return return
} }
strCallPath = "_" + vstr[1] + ".HTTP_" + vstr[2] strCallPath = "_" + vstr[0] + ".HTTP_" + vstr[1]
} }
defer r.Body.Close() defer r.Body.Close()
@@ -228,7 +230,7 @@ func (slf *ServeHTTPRouterMux) ServeHTTP(w http.ResponseWriter, r *http.Request)
return return
} }
request := HttpRequest{r.Header, string(msg), r.URL.RawQuery, nil} request := HttpRequest{r.Header, string(msg), r.URL.RawQuery, nil,r.URL.Path}
var resp HttpRespone var resp HttpRespone
//resp.Resp = w //resp.Resp = w
timeFuncStart := time.Now() timeFuncStart := time.Now()