initial import

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-03-30 02:24:54 +03:00
commit 3f5fc8ec06
5 changed files with 440 additions and 0 deletions

57
request.go Normal file
View File

@@ -0,0 +1,57 @@
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
}