MCPcopy Create free account
hub / github.com/cloudwego/dynamicgo / ExampleHTTPConv_DoInto

Function ExampleHTTPConv_DoInto

conv/t2j/example_test.go:48–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46}
47
48func ExampleHTTPConv_DoInto() {
49 // get function descriptor
50 desc := thrift.GetFnDescFromFile("testdata/idl/example3.thrift", "ExampleMethod", thrift.Options{})
51
52 // make thrift message
53 data := getExample3Data()
54 in, err := thrift.WrapBinaryBody(data, "ExampleMethod", thrift.REPLY, thrift.FieldID(0), 1)
55 if err != nil {
56 panic(err)
57 }
58
59 // get http.ResponseSetter
60 resp := http.NewHTTPResponse()
61 resp.StatusCode = 200
62
63 // make HTTPConv
64 cv := NewHTTPConv(meta.EncodingThriftBinary, desc)
65
66 // do conversion
67 buf := make([]byte, 0, len(data)*2)
68 err = cv.DoInto(context.Background(), resp, in, &buf, opts)
69 if err != nil {
70 panic(err)
71 }
72
73 // validate result
74 var act example3.ExampleResp
75 err = json.Unmarshal(buf, &act)
76 if err != nil {
77 panic(err)
78 }
79 // non-http annotations fields
80 spew.Dump(act)
81 // http annotations fields
82 spew.Dump(resp)
83}

Callers

nothing calls this directly

Calls 7

DoIntoMethod · 0.95
GetFnDescFromFileFunction · 0.92
WrapBinaryBodyFunction · 0.92
FieldIDTypeAlias · 0.92
NewHTTPResponseFunction · 0.92
getExample3DataFunction · 0.70
NewHTTPConvFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…