forked from st3v/go-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.go
61 lines (49 loc) · 1.09 KB
/
request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package http
import (
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/codec"
)
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
}
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
}
func (h *httpRequest) Method() string {
return h.method
}
func (h *httpRequest) Endpoint() string {
return h.method
}
func (h *httpRequest) Codec() codec.Writer {
return nil
}
func (h *httpRequest) Body() interface{} {
return h.request
}
func (h *httpRequest) Stream() bool {
return h.opts.Stream
}