/
city.pb.cdd.go
86 lines (68 loc) · 2.58 KB
/
city.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
77
78
79
80
81
82
83
84
85
86
// Code generated by protoc-gen-cdd. DO NOT EDIT.
// source: city.proto
package city
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 {
City_Get string
City_Search string
City_FileDownload string
}
var FullMethods = fullMethods{
City_Get: "/city.city/Get",
City_Search: "/city.city/Search",
City_FileDownload: "/city.city/FileDownload",
}
var NeedAuthFullMethods = []string{}
type AuthConfig struct {
NeedAuth bool
Roles []string
}
var AuthConfigFullMethods = map[string]AuthConfig{
"/city.city/Get": AuthConfig{NeedAuth: false, Roles: []string{"*"}},
"/city.city/Search": AuthConfig{NeedAuth: false, Roles: []string{"*"}},
"/city.city/FileDownload": 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
}
/*==================== City Section ====================*/
func RegisterCityGrstServer(grpcRestServer *grst.Server, hndl CityServer) {
forward_City_Get_0 = grpcRestServer.GetForwardResponseMessage()
forward_City_Search_0 = grpcRestServer.GetForwardResponseMessage()
forward_City_FileDownload_0 = grpcRestServer.GetForwardResponseMessage()
RegisterCityServer(grpcRestServer.GetGrpcServer(), hndl)
grpcRestServer.RegisterRestHandler(RegisterCityHandler)
}
func NewCityGrstClient(serverHost string, creds *credentials.TransportCredentials, dialOpts ...grpc.DialOption) (CityClient, 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 NewCityClient(grpcConn), err
}