forked from ravendb/ravendb-go-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream_command.go
47 lines (34 loc) · 902 Bytes
/
stream_command.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
package ravendb
import (
"net/http"
)
var (
_ RavenCommand = &StreamCommand{}
)
type StreamCommand struct {
RavenCommandBase
_url string
Result *StreamResultResponse
}
func NewStreamCommand(url string) *StreamCommand {
// TODO: validate url
cmd := &StreamCommand{
RavenCommandBase: NewRavenCommandBase(),
_url: url,
}
cmd.IsReadRequest = true
return cmd
}
func (c *StreamCommand) CreateRequest(node *ServerNode) (*http.Request, error) {
url := node.URL + "/databases/" + node.Database + "/" + c._url
return newHttpGet(url)
}
func (c *StreamCommand) processResponse(cache *httpCache, response *http.Response, url string) (responseDisposeHandling, error) {
// TODO: return an error if response.Body is nil
streamResponse := &StreamResultResponse{
Response: response,
Stream: response.Body,
}
c.Result = streamResponse
return responseDisposeHandlingManually, nil
}