()
| 46 | } |
| 47 | |
| 48 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…