micro-client-http/request.go

62 lines
1.1 KiB
Go
Raw Normal View History

2017-01-01 21:39:05 +03:00
package http
import (
"github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/codec"
2017-01-01 21:39:05 +03:00
)
type httpRequest struct {
service string
method string
contentType string
request interface{}
opts client.RequestOptions
}
func newHTTPRequest(service, method string, request interface{}, contentType string, reqOpts ...client.RequestOption) client.Request {
var opts client.RequestOptions
for _, o := range reqOpts {
o(&opts)
}
if len(opts.ContentType) > 0 {
contentType = opts.ContentType
}
2017-01-01 21:39:05 +03:00
return &httpRequest{
service: service,
method: method,
request: request,
contentType: contentType,
opts: opts,
}
}
func (h *httpRequest) ContentType() string {
return h.contentType
}
func (h *httpRequest) Service() string {
return h.service
}
2019-01-18 18:47:50 +03:00
func (h *httpRequest) Method() string {
return h.method
}
2019-01-11 01:12:43 +03:00
func (h *httpRequest) Endpoint() string {
2017-01-01 21:39:05 +03:00
return h.method
}
2019-01-10 14:59:45 +03:00
func (h *httpRequest) Codec() codec.Writer {
return nil
}
func (h *httpRequest) Body() interface{} {
2017-01-01 21:39:05 +03:00
return h.request
}
func (h *httpRequest) Stream() bool {
return h.opts.Stream
}