forked from nytimes/gizmo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cats.go
32 lines (26 loc) · 739 Bytes
/
cats.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
package service
import (
"net/http"
"github.com/NYTimes/gizmo/examples/nyt"
"github.com/NYTimes/gizmo/server"
"golang.org/x/net/context"
)
func (s *RPCService) GetCats(ctx context.Context, r *CatsRequest) (*CatsResponse, error) {
var (
err error
res []*nyt.SemanticConceptArticle
)
defer server.MonitorRPCRequest()(ctx, "GetCats", &err)
res, err = s.client.SemanticConceptSearch("des", "cats")
if err != nil {
return nil, err
}
return &CatsResponse{res}, nil
}
func (s *RPCService) GetCatsJSON(ctx context.Context, r *http.Request) (int, interface{}, error) {
res, err := s.GetCats(ctx, &CatsRequest{})
if err != nil {
return http.StatusInternalServerError, nil, err
}
return http.StatusOK, res.Results, nil
}