未验证 提交 44f9d303 编写于 作者: E Eolink 提交者: GitHub

Merge pull request #78 from Dot-Liu/master

严格类型检查
......@@ -44,7 +44,15 @@ func (b *Layer) Send(deadline context.Context, ctx *common.Context, variables *i
if method == "FOLLOW" {
method = ctx.ProxyRequest.Method
}
r, finalTargetServer, retryTargetServers, err := b.Balance.Send(ctx, b.Protocol, method, path, ctx.ProxyRequest.Querys(), ctx.ProxyRequest.Headers(), []byte(body), b.TimeOut, b.Retry)
header:= ctx.ProxyRequest.Headers()
if b.Encode == "json"{
header.Set("content-type","application/json; charset=utf-8")
} else if b.Encode == "xml" {
header.Set("content-type","application/xml; charset=utf-8")
}
r, finalTargetServer, retryTargetServers, err := b.Balance.Send(ctx, b.Protocol, method, path, nil, header, []byte(body), b.TimeOut, b.Retry)
if err != nil {
return nil, err
......
......@@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"reflect"
"strconv"
)
//Reader reder
......@@ -72,6 +73,15 @@ func find(node *reflect.Value, path []string) string {
next := node.MapIndex(key)
return find(&next, path[1:])
}
case reflect.Slice:
{
index,err:= strconv.Atoi(path[0])
if err!= nil{
return ""
}
next :=node.Index(index)
return find(&next,path[1:])
}
default:
return ""
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册