2021-01-19 04:15:57 +03:00
|
|
|
// Code generated by protoc-gen-micro
|
|
|
|
// source: github.proto
|
|
|
|
package pb
|
|
|
|
|
|
|
|
import (
|
2021-02-27 13:51:39 +03:00
|
|
|
context "context"
|
|
|
|
v3 "github.com/unistack-org/micro-client-http/v3"
|
|
|
|
api "github.com/unistack-org/micro/v3/api"
|
|
|
|
client "github.com/unistack-org/micro/v3/client"
|
|
|
|
server "github.com/unistack-org/micro/v3/server"
|
2021-03-30 18:34:04 +03:00
|
|
|
http "net/http"
|
2021-01-19 04:15:57 +03:00
|
|
|
)
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
type githubClient struct {
|
|
|
|
c client.Client
|
2021-01-19 04:15:57 +03:00
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func NewGithubClient(name string, c client.Client) GithubClient {
|
|
|
|
return &githubClient{c: c, name: name}
|
2021-01-19 04:15:57 +03:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func (c *githubClient) LookupUser(ctx context.Context, req *LookupUserReq, opts ...client.CallOption) (*LookupUserRsp, error) {
|
2021-01-19 04:15:57 +03:00
|
|
|
errmap := make(map[string]interface{}, 1)
|
|
|
|
errmap["default"] = &Error{}
|
2021-02-27 13:51:39 +03:00
|
|
|
opts = append(opts,
|
|
|
|
v3.ErrorMap(errmap),
|
2021-03-22 00:10:15 +03:00
|
|
|
)
|
|
|
|
opts = append(opts,
|
2021-03-30 18:34:04 +03:00
|
|
|
v3.Method(http.MethodGet),
|
2021-02-27 13:51:39 +03:00
|
|
|
v3.Path("/users/{username}"),
|
2021-01-19 04:15:57 +03:00
|
|
|
)
|
|
|
|
rsp := &LookupUserRsp{}
|
2021-02-27 13:51:39 +03:00
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Github.LookupUser", req), rsp, opts...)
|
2021-01-19 04:15:57 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
2021-03-30 18:34:04 +03:00
|
|
|
func (c *githubClient) LookupUserWithoutPath(ctx context.Context, req *LookupUserReq, opts ...client.CallOption) (*LookupUserRsp, error) {
|
|
|
|
errmap := make(map[string]interface{}, 1)
|
|
|
|
errmap["default"] = &Error{}
|
|
|
|
opts = append(opts,
|
|
|
|
v3.ErrorMap(errmap),
|
|
|
|
)
|
|
|
|
opts = append(opts,
|
|
|
|
v3.Method(http.MethodGet),
|
|
|
|
v3.Path("/{username}"),
|
|
|
|
)
|
|
|
|
rsp := &LookupUserRsp{}
|
|
|
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Github.LookupUserWithoutPath", req), rsp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return rsp, nil
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
type githubServer struct {
|
|
|
|
GithubServer
|
2021-01-19 04:15:57 +03:00
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func (h *githubServer) LookupUser(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error {
|
|
|
|
return h.GithubServer.LookupUser(ctx, req, rsp)
|
2021-01-19 04:15:57 +03:00
|
|
|
}
|
|
|
|
|
2021-03-30 18:34:04 +03:00
|
|
|
func (h *githubServer) LookupUserWithoutPath(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error {
|
|
|
|
return h.GithubServer.LookupUserWithoutPath(ctx, req, rsp)
|
|
|
|
}
|
|
|
|
|
2021-02-27 13:51:39 +03:00
|
|
|
func RegisterGithubServer(s server.Server, sh GithubServer, opts ...server.HandlerOption) error {
|
|
|
|
type github interface {
|
|
|
|
LookupUser(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error
|
2021-03-30 18:34:04 +03:00
|
|
|
LookupUserWithoutPath(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error
|
2021-02-27 13:51:39 +03:00
|
|
|
}
|
|
|
|
type Github struct {
|
|
|
|
github
|
|
|
|
}
|
|
|
|
h := &githubServer{sh}
|
2021-03-30 18:34:04 +03:00
|
|
|
var nopts []server.HandlerOption
|
2021-02-27 13:51:39 +03:00
|
|
|
for _, endpoint := range NewGithubEndpoints() {
|
2021-03-30 18:34:04 +03:00
|
|
|
nopts = append(nopts, api.WithEndpoint(endpoint))
|
2021-02-27 13:51:39 +03:00
|
|
|
}
|
2021-03-30 18:34:04 +03:00
|
|
|
return s.Handle(s.NewHandler(&Github{h}, append(nopts, opts...)...))
|
2021-01-19 04:15:57 +03:00
|
|
|
}
|