micro-client-http/request.go
Vasiliy Tolstov 8de525a8f8 update for latest micro changes
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-12 13:17:47 +03:00

59 lines
1.1 KiB
Go

package http
import (
"go.unistack.org/micro/v4/client"
"go.unistack.org/micro/v4/codec"
"go.unistack.org/micro/v4/options"
)
type httpRequest struct {
service string
method string
contentType string
request interface{}
opts client.RequestOptions
}
func newHTTPRequest(service, method string, request interface{}, contentType string, opts ...options.Option) client.Request {
options := client.NewRequestOptions(opts...)
if len(options.ContentType) == 0 {
options.ContentType = contentType
}
return &httpRequest{
service: service,
method: method,
request: request,
contentType: options.ContentType,
opts: options,
}
}
func (h *httpRequest) ContentType() string {
return h.contentType
}
func (h *httpRequest) Service() string {
return h.service
}
func (h *httpRequest) Method() string {
return h.method
}
func (h *httpRequest) Endpoint() string {
return h.method
}
func (h *httpRequest) Codec() codec.Codec {
return nil
}
func (h *httpRequest) Body() interface{} {
return h.request
}
func (h *httpRequest) Stream() bool {
return h.opts.Stream
}