2017-01-01 18:39:05 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2021-01-10 14:48:10 +03:00
|
|
|
"github.com/unistack-org/micro/v3/client"
|
|
|
|
"github.com/unistack-org/micro/v3/codec"
|
2017-01-01 18:39:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type httpRequest struct {
|
|
|
|
service string
|
|
|
|
method string
|
|
|
|
contentType string
|
|
|
|
request interface{}
|
|
|
|
opts client.RequestOptions
|
|
|
|
}
|
|
|
|
|
2021-01-10 14:48:10 +03:00
|
|
|
func newHTTPRequest(service, method string, request interface{}, contentType string, opts ...client.RequestOption) client.Request {
|
|
|
|
options := client.NewRequestOptions(opts...)
|
|
|
|
if len(options.ContentType) == 0 {
|
|
|
|
options.ContentType = contentType
|
2018-04-17 12:12:51 +01:00
|
|
|
}
|
|
|
|
|
2017-01-01 18:39:05 +00:00
|
|
|
return &httpRequest{
|
|
|
|
service: service,
|
|
|
|
method: method,
|
|
|
|
request: request,
|
2021-01-10 14:48:10 +03:00
|
|
|
contentType: options.ContentType,
|
|
|
|
opts: options,
|
2017-01-01 18:39:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRequest) ContentType() string {
|
|
|
|
return h.contentType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRequest) Service() string {
|
|
|
|
return h.service
|
|
|
|
}
|
|
|
|
|
2019-01-18 15:47:50 +00:00
|
|
|
func (h *httpRequest) Method() string {
|
|
|
|
return h.method
|
|
|
|
}
|
|
|
|
|
2019-01-10 22:12:43 +00:00
|
|
|
func (h *httpRequest) Endpoint() string {
|
2017-01-01 18:39:05 +00:00
|
|
|
return h.method
|
|
|
|
}
|
|
|
|
|
2021-01-10 14:48:10 +03:00
|
|
|
func (h *httpRequest) Codec() codec.Codec {
|
2019-01-10 11:59:45 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRequest) Body() interface{} {
|
2017-01-01 18:39:05 +00:00
|
|
|
return h.request
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRequest) Stream() bool {
|
|
|
|
return h.opts.Stream
|
|
|
|
}
|