Chromium Code Reviews| Index: go/src/infra/monorail/endpoints.go |
| diff --git a/go/src/infra/monorail/endpoints.go b/go/src/infra/monorail/endpoints.go |
| index fffac476a774b97aacd7a92689db71aea2a3ed1f..1472ede233ce63d9bd7bd46ee6185e8f26a44a77 100644 |
| --- a/go/src/infra/monorail/endpoints.go |
| +++ b/go/src/infra/monorail/endpoints.go |
| @@ -11,6 +11,7 @@ import ( |
| "io" |
| "io/ioutil" |
| "net/http" |
| + "net/url" |
| "strings" |
| "golang.org/x/net/context" |
| @@ -46,7 +47,7 @@ func NewEndpointsClient(client *http.Client, url string) MonorailClient { |
| return &epClient{HTTP: client, url: strings.TrimSuffix(url, "/")} |
| } |
| -func (c *epClient) call(ctx context.Context, urlSuffix string, request, response interface{}) error { |
| +func (c *epClient) call(ctx context.Context, method, urlSuffix string, request, response interface{}) error { |
| client := c.HTTP |
| if client == nil { |
| client = http.DefaultClient |
| @@ -69,7 +70,7 @@ func (c *epClient) call(ctx context.Context, urlSuffix string, request, response |
| } |
| // Make an HTTP request. |
| - req, err := http.NewRequest("POST", c.url + urlSuffix, reqBuf) |
| + req, err := http.NewRequest(method, c.url+urlSuffix, reqBuf) |
| if err != nil { |
| return fmt.Errorf("could not make a request to %s: %s", req.URL, err) |
| } |
| @@ -77,7 +78,7 @@ func (c *epClient) call(ctx context.Context, urlSuffix string, request, response |
| req.Header.Set("Accept", "application/json") |
| // Send the request. |
| - logging.Debugf(ctx, "POST %s %s", req.URL, reqBuf.Bytes()) |
| + logging.Debugf(ctx, "%s %s %s", method, req.URL, reqBuf.Bytes()) |
| res, err := ctxhttp.Do(ctx, client, req) |
| if err != nil { |
| return errors.WrapTransient(err) |
| @@ -111,7 +112,7 @@ func (c *epClient) InsertIssue(ctx context.Context, req *InsertIssueRequest, opt |
| } |
| url := fmt.Sprintf("/projects/%s/issues?sendEmail=%v", req.ProjectId, req.SendEmail) |
| res := &InsertIssueResponse{&Issue{}} |
| - return res, c.call(ctx, url, &req.Issue, res.Issue) |
| + return res, c.call(ctx, "POST", url, &req.Issue, res.Issue) |
| } |
| func (c *epClient) InsertComment(ctx context.Context, req *InsertCommentRequest, options ...grpc.CallOption) (*InsertCommentResponse, error) { |
| @@ -119,7 +120,25 @@ func (c *epClient) InsertComment(ctx context.Context, req *InsertCommentRequest, |
| return nil, err |
| } |
| url := fmt.Sprintf("/projects/%s/issues/%d/comments", req.Issue.ProjectId, req.Issue.IssueId) |
| - return &InsertCommentResponse{}, c.call(ctx, url, req.Comment, nil) |
| + return &InsertCommentResponse{}, c.call(ctx, "POST", url, req.Comment, nil) |
| +} |
| + |
| +func (c *epClient) IssuesList(ctx context.Context, req *IssuesListRequest, options ...grpc.CallOption) (*IssuesListResponse, error) { |
| + if err := checkOptions(options); err != nil { |
| + return nil, err |
| + } |
| + |
| + args := url.Values{} |
| + args.Set("can", strings.ToLower(req.Can.String())) |
| + args.Set("q", req.Q) |
|
nodir
2016/06/09 15:55:55
other values are still ignored, e.g. "label"
pleas
seanmccullough1
2016/06/09 16:11:40
Done.
|
| + |
| + url := fmt.Sprintf("/projects/%s/issues?%s", req.ProjectId, args.Encode()) |
| + res := &IssuesListResponse{} |
| + err := c.call(ctx, "GET", url, nil, res) |
| + if err != nil { |
| + return nil, err |
| + } |
| + return res, nil |
| } |
| func checkOptions(options []grpc.CallOption) error { |