61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
|
// Code generated by protoc-gen-micro
|
||
|
// source: github.proto
|
||
|
package pb
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
micro_client_http "github.com/unistack-org/micro-client-http/v3"
|
||
|
micro_client "github.com/unistack-org/micro/v3/client"
|
||
|
micro_server "github.com/unistack-org/micro/v3/server"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
_ micro_server.Option
|
||
|
_ micro_client.Option
|
||
|
)
|
||
|
|
||
|
type githubService struct {
|
||
|
c micro_client.Client
|
||
|
name string
|
||
|
}
|
||
|
|
||
|
// Micro client stuff
|
||
|
|
||
|
// NewGithubService create new service client
|
||
|
func NewGithubService(name string, c micro_client.Client) GithubService {
|
||
|
return &githubService{c: c, name: name}
|
||
|
}
|
||
|
|
||
|
func (c *githubService) LookupUser(ctx context.Context, req *LookupUserReq, opts ...micro_client.CallOption) (*LookupUserRsp, error) {
|
||
|
errmap := make(map[string]interface{}, 1)
|
||
|
errmap["default"] = &Error{}
|
||
|
nopts := append(opts,
|
||
|
micro_client_http.Method("GET"),
|
||
|
micro_client_http.Path("/users/{username}"),
|
||
|
micro_client_http.ErrorMap(errmap),
|
||
|
)
|
||
|
rsp := &LookupUserRsp{}
|
||
|
err := c.c.Call(ctx, c.c.NewRequest(c.name, "Github.LookupUser", req), rsp, nopts...)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return rsp, nil
|
||
|
}
|
||
|
|
||
|
// Error method to satisfy error interface
|
||
|
func (e *Error) Error() string {
|
||
|
return fmt.Sprintf("%#v", e)
|
||
|
}
|
||
|
|
||
|
// Micro server stuff
|
||
|
|
||
|
type githubHandler struct {
|
||
|
GithubHandler
|
||
|
}
|
||
|
|
||
|
func (h *githubHandler) LookupUser(ctx context.Context, req *LookupUserReq, rsp *LookupUserRsp) error {
|
||
|
return h.GithubHandler.LookupUser(ctx, req, rsp)
|
||
|
}
|