micro-client-http/request.go

58 lines
1.1 KiB
Go
Raw Normal View History

2017-01-01 21:39:05 +03:00
package http
import (
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/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, opts ...client.RequestOption) client.Request {
options := client.NewRequestOptions(opts...)
if len(options.ContentType) == 0 {
options.ContentType = contentType
}
2017-01-01 21:39:05 +03:00
return &httpRequest{
service: service,
method: method,
request: request,
contentType: options.ContentType,
opts: options,
2017-01-01 21:39:05 +03:00
}
}
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
}
func (h *httpRequest) Codec() codec.Codec {
2019-01-10 14:59:45 +03:00
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
}