micro-client-mock/request.go
Vasiliy Tolstov 3f5fc8ec06 initial import
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-03-30 02:24:54 +03:00

58 lines
1.1 KiB
Go

package mock
import (
"go.unistack.org/micro/v3/client"
"go.unistack.org/micro/v3/codec"
)
type mockRequest struct {
service string
method string
contentType string
request interface{}
opts client.RequestOptions
}
func newRequest(service, method string, request interface{}, contentType string, opts ...client.RequestOption) client.Request {
options := client.NewRequestOptions(opts...)
if len(options.ContentType) == 0 {
options.ContentType = contentType
}
return &mockRequest{
service: service,
method: method,
request: request,
contentType: options.ContentType,
opts: options,
}
}
func (r *mockRequest) ContentType() string {
return r.contentType
}
func (r *mockRequest) Service() string {
return r.service
}
func (r *mockRequest) Method() string {
return r.method
}
func (r *mockRequest) Endpoint() string {
return r.method
}
func (r *mockRequest) Codec() codec.Codec {
return nil
}
func (r *mockRequest) Body() interface{} {
return r.request
}
func (r *mockRequest) Stream() bool {
return r.opts.Stream
}