forked from Scalingo/go-scalingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs.go
42 lines (36 loc) · 951 Bytes
/
logs.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
package scalingo
import (
"net/http"
"net/url"
httpclient "github.com/Scalingo/go-scalingo/http"
"gopkg.in/errgo.v1"
)
type LogsService interface {
LogsURL(app string) (*http.Response, error)
Logs(logsURL string, n int, filter string) (*http.Response, error)
}
var _ LogsService = (*Client)(nil)
func (c *Client) LogsURL(app string) (*http.Response, error) {
req := &httpclient.APIRequest{
Endpoint: "/apps/" + app + "/logs",
}
return c.ScalingoAPI().Do(req)
}
func (c *Client) Logs(logsURL string, n int, filter string) (*http.Response, error) {
u, err := url.Parse(logsURL)
if err != nil {
return nil, errgo.Mask(err)
}
req := &httpclient.APIRequest{
NoAuth: true,
Expected: httpclient.Statuses{200, 204, 404},
URL: u.Scheme + "://" + u.Host,
Endpoint: u.Path,
Params: map[string]interface{}{
"token": u.Query().Get("token"),
"n": n,
"filter": filter,
},
}
return c.ScalingoAPI().Do(req)
}