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