github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/util/cache/test_request.go (about) 1 package cache 2 3 import ( 4 "github.com/tickoalcantara12/micro/v3/service/client" 5 "github.com/tickoalcantara12/micro/v3/util/codec" 6 ) 7 8 type testRequest struct { 9 service string 10 method string 11 endpoint string 12 contentType string 13 codec codec.Codec 14 body interface{} 15 opts client.RequestOptions 16 } 17 18 func newRequest(service, endpoint string, request interface{}, contentType string, reqOpts ...client.RequestOption) client.Request { 19 var opts client.RequestOptions 20 21 for _, o := range reqOpts { 22 o(&opts) 23 } 24 25 // set the content-type specified 26 if len(opts.ContentType) > 0 { 27 contentType = opts.ContentType 28 } 29 30 return &testRequest{ 31 service: service, 32 method: endpoint, 33 endpoint: endpoint, 34 body: request, 35 contentType: contentType, 36 opts: opts, 37 } 38 } 39 40 func (r *testRequest) ContentType() string { 41 return r.contentType 42 } 43 44 func (r *testRequest) Service() string { 45 return r.service 46 } 47 48 func (r *testRequest) Method() string { 49 return r.method 50 } 51 52 func (r *testRequest) Endpoint() string { 53 return r.endpoint 54 } 55 56 func (r *testRequest) Body() interface{} { 57 return r.body 58 } 59 60 func (r *testRequest) Codec() codec.Writer { 61 return r.codec 62 } 63 64 func (r *testRequest) Stream() bool { 65 return r.opts.Stream 66 }