-
Notifications
You must be signed in to change notification settings - Fork 0
/
users.pb.cdd.go
76 lines (60 loc) · 2.17 KB
/
users.pb.cdd.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Code generated by protoc-gen-cdd. DO NOT EDIT.
// source: users.proto
package users
import (
"net/http"
"strings"
"github.com/krisnasw/go-grst/grst"
grst_errors "github.com/krisnasw/go-grst/grst/errors"
"google.golang.org/grpc"
"github.com/mcuadros/go-defaults"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"gopkg.in/validator.v2"
)
type fullMethods struct {
Users_GetProfile string
}
var FullMethods = fullMethods{
Users_GetProfile: "/users.users/GetProfile",
}
var NeedAuthFullMethods = []string{}
type AuthConfig struct {
NeedAuth bool
Roles []string
}
var AuthConfigFullMethods = map[string]AuthConfig{
"/users.users/GetProfile": AuthConfig{NeedAuth: false, Roles: []string{"*"}},
}
var NeedApiKeyFullMethods = []string{}
func ValidateRequest(req interface{}) error {
defaults.SetDefaults(req)
if errs := validator.Validate(req); errs != nil {
validateError := []*grst_errors.ErrorDetail{}
for field, err := range errs.(validator.ErrorMap) {
errMessage := strings.Replace(err.Error(), "{field}", field, -1)
validateError = append(validateError, &grst_errors.ErrorDetail{Code: 999, Field: field, Message: errMessage})
}
return grst_errors.New(http.StatusBadRequest, codes.InvalidArgument, 999, "Validation Error", validateError...)
}
return nil
}
/*==================== Users Section ====================*/
func RegisterUsersGrstServer(grpcRestServer *grst.Server, hndl UsersServer) {
forward_Users_GetProfile_0 = grpcRestServer.GetForwardResponseMessage()
RegisterUsersServer(grpcRestServer.GetGrpcServer(), hndl)
grpcRestServer.RegisterRestHandler(RegisterUsersHandler)
}
func NewUsersGrstClient(serverHost string, creds *credentials.TransportCredentials, dialOpts ...grpc.DialOption) (UsersClient, error) {
opts := []grpc.DialOption{}
opts = append(opts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(1024*1024*20)))
opts = append(opts, grpc.WithMaxMsgSize(1024*1024*20))
if creds == nil {
opts = append(opts, grpc.WithInsecure())
} else {
opts = append(opts, grpc.WithTransportCredentials(*creds))
}
opts = append(opts, dialOpts...)
grpcConn, err := grpc.Dial(serverHost, opts...)
return NewUsersClient(grpcConn), err
}