Files
micro-client-mock/request.go
Vasiliy Tolstov a3bba7818d move to micro v4
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-03-04 22:38:41 +03:00

58 lines
1.1 KiB
Go

package mock
import (
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/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
}