micro-client-http/request.go

58 lines
1.1 KiB
Go
Raw Permalink Normal View History

2017-01-01 18:39:05 +00:00
package http
import (
"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
}
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
}
2017-01-01 18:39:05 +00:00
return &httpRequest{
service: service,
method: method,
request: request,
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
}
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
}