add additional wrappers support #66
20
.github/workflows/autoapprove.yml
vendored
Normal file
20
.github/workflows/autoapprove.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: "autoapprove"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [assigned, opened, synchronize, reopened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
autoapprove:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: approve
|
||||||
|
uses: hmarr/auto-approve-action@v2
|
||||||
|
if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]'
|
||||||
|
id: approve
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
21
.github/workflows/automerge.yml
vendored
Normal file
21
.github/workflows/automerge.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: "automerge"
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [assigned, opened, synchronize, reopened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
automerge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.actor == 'vtolstov'
|
||||||
|
steps:
|
||||||
|
- name: merge
|
||||||
|
id: merge
|
||||||
|
run: gh pr merge --auto --merge "$PR_URL"
|
||||||
|
env:
|
||||||
|
PR_URL: ${{github.event.pull_request.html_url}}
|
||||||
|
GITHUB_TOKEN: ${{secrets.TOKEN}}
|
12
.github/workflows/dependabot-automerge.yml
vendored
12
.github/workflows/dependabot-automerge.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: "prautomerge"
|
name: "dependabot-automerge"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
@ -9,21 +9,17 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
dependabot:
|
automerge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.actor == 'dependabot[bot]' }}
|
if: github.actor == 'dependabot[bot]'
|
||||||
steps:
|
steps:
|
||||||
- name: metadata
|
- name: metadata
|
||||||
id: metadata
|
id: metadata
|
||||||
uses: dependabot/fetch-metadata@v1.3.0
|
uses: dependabot/fetch-metadata@v1.3.0
|
||||||
with:
|
with:
|
||||||
github-token: "${{ secrets.TOKEN }}"
|
github-token: "${{ secrets.TOKEN }}"
|
||||||
- name: approve
|
|
||||||
run: gh pr review --approve "$PR_URL"
|
|
||||||
env:
|
|
||||||
PR_URL: ${{github.event.pull_request.html_url}}
|
|
||||||
GITHUB_TOKEN: ${{secrets.TOKEN}}
|
|
||||||
- name: merge
|
- name: merge
|
||||||
|
id: merge
|
||||||
if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
|
if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
|
||||||
run: gh pr merge --auto --merge "$PR_URL"
|
run: gh pr merge --auto --merge "$PR_URL"
|
||||||
env:
|
env:
|
||||||
|
25
http.go
25
http.go
@ -604,6 +604,8 @@ func (h *httpClient) Publish(ctx context.Context, p client.Message, opts ...clie
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...client.PublishOption) error {
|
func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...client.PublishOption) error {
|
||||||
|
var body []byte
|
||||||
|
|
||||||
options := client.NewPublishOptions(opts...)
|
options := client.NewPublishOptions(opts...)
|
||||||
|
|
||||||
// get proxy
|
// get proxy
|
||||||
@ -622,24 +624,22 @@ func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...c
|
|||||||
for _, p := range ps {
|
for _, p := range ps {
|
||||||
md := metadata.Copy(omd)
|
md := metadata.Copy(omd)
|
||||||
md[metadata.HeaderContentType] = p.ContentType()
|
md[metadata.HeaderContentType] = p.ContentType()
|
||||||
md[metadata.HeaderTopic] = p.Topic()
|
|
||||||
|
|
||||||
cf, err := h.newCodec(p.ContentType())
|
|
||||||
if err != nil {
|
|
||||||
return errors.InternalServerError("go.micro.client", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
var body []byte
|
|
||||||
|
|
||||||
// passed in raw data
|
// passed in raw data
|
||||||
if d, ok := p.Payload().(*codec.Frame); ok {
|
if d, ok := p.Payload().(*codec.Frame); ok {
|
||||||
body = d.Data
|
body = d.Data
|
||||||
} else {
|
} else {
|
||||||
b := bytes.NewBuffer(nil)
|
// use codec for payload
|
||||||
if err := cf.Write(b, &codec.Message{Type: codec.Event}, p.Payload()); err != nil {
|
cf, err := h.newCodec(p.ContentType())
|
||||||
|
if err != nil {
|
||||||
return errors.InternalServerError("go.micro.client", err.Error())
|
return errors.InternalServerError("go.micro.client", err.Error())
|
||||||
}
|
}
|
||||||
body = b.Bytes()
|
// set the body
|
||||||
|
b, err := cf.Marshal(p.Payload())
|
||||||
|
if err != nil {
|
||||||
|
return errors.InternalServerError("go.micro.client", err.Error())
|
||||||
|
}
|
||||||
|
body = b
|
||||||
}
|
}
|
||||||
|
|
||||||
topic := p.Topic()
|
topic := p.Topic()
|
||||||
@ -647,6 +647,9 @@ func (h *httpClient) publish(ctx context.Context, ps []client.Message, opts ...c
|
|||||||
topic = exchange
|
topic = exchange
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for k, v := range p.Metadata() {
|
||||||
|
md.Set(k, v)
|
||||||
|
}
|
||||||
md.Set(metadata.HeaderTopic, topic)
|
md.Set(metadata.HeaderTopic, topic)
|
||||||
msgs = append(msgs, &broker.Message{Header: md, Body: body})
|
msgs = append(msgs, &broker.Message{Header: md, Body: body})
|
||||||
}
|
}
|
||||||
|
37
util.go
37
util.go
@ -147,11 +147,11 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
|
|||||||
switch val.Type().Kind() {
|
switch val.Type().Kind() {
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
for idx := 0; idx < val.Len(); idx++ {
|
for idx := 0; idx < val.Len(); idx++ {
|
||||||
values.Add(t.name, fmt.Sprintf("%v", val.Index(idx).Interface()))
|
values.Add(t.name, getParam(val.Index(idx)))
|
||||||
}
|
}
|
||||||
fieldsmapskip[t.name] = struct{}{}
|
fieldsmapskip[t.name] = struct{}{}
|
||||||
default:
|
default:
|
||||||
fieldsmap[t.name] = fmt.Sprintf("%v", val.Interface())
|
fieldsmap[t.name] = getParam(val)
|
||||||
}
|
}
|
||||||
} else if (body == "*" || body == t.name) && method != http.MethodGet {
|
} else if (body == "*" || body == t.name) && method != http.MethodGet {
|
||||||
if tnmsg.Field(i).CanSet() {
|
if tnmsg.Field(i).CanSet() {
|
||||||
@ -160,10 +160,10 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
|
|||||||
} else {
|
} else {
|
||||||
if val.Type().Kind() == reflect.Slice {
|
if val.Type().Kind() == reflect.Slice {
|
||||||
for idx := 0; idx < val.Len(); idx++ {
|
for idx := 0; idx < val.Len(); idx++ {
|
||||||
values.Add(t.name, fmt.Sprintf("%v", val.Index(idx).Interface()))
|
values.Add(t.name, getParam(val.Index(idx)))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
values.Add(t.name, fmt.Sprintf("%v", val.Interface()))
|
values.Add(t.name, getParam(val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,12 +216,6 @@ func newPathRequest(path string, method string, body string, msg interface{}, ta
|
|||||||
_, _ = b.WriteString(values.Encode())
|
_, _ = b.WriteString(values.Encode())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if err = rutil.ZeroFieldByPath(nmsg, k); err != nil {
|
|
||||||
return nil, errors.BadRequest("go.micro.client", err.Error())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if rutil.IsZero(nmsg) {
|
if rutil.IsZero(nmsg) {
|
||||||
return b.String(), nil, nil
|
return b.String(), nil, nil
|
||||||
}
|
}
|
||||||
@ -324,3 +318,26 @@ type tag struct {
|
|||||||
key string
|
key string
|
||||||
name string
|
name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getParam(val reflect.Value) string {
|
||||||
|
var v string
|
||||||
|
switch val.Kind() {
|
||||||
|
case reflect.Ptr:
|
||||||
|
switch reflect.Indirect(val).Type().String() {
|
||||||
|
case
|
||||||
|
"wrapperspb.BoolValue",
|
||||||
|
"wrapperspb.BytesValue",
|
||||||
|
"wrapperspb.DoubleValue",
|
||||||
|
"wrapperspb.FloatValue",
|
||||||
|
"wrapperspb.Int32Value", "wrapperspb.Int64Value",
|
||||||
|
"wrapperspb.StringValue",
|
||||||
|
"wrapperspb.UInt32Value", "wrapperspb.UInt64Value":
|
||||||
|
if eva := reflect.Indirect(val).FieldByName("Value"); eva.IsValid() {
|
||||||
|
v = getParam(eva)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
v = fmt.Sprintf("%v", val.Interface())
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user