-
Notifications
You must be signed in to change notification settings - Fork 81
/
interface_with_grpc_validation.go
executable file
·38 lines (30 loc) · 1.38 KB
/
interface_with_grpc_validation.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
package templatestests
// DO NOT EDIT!
// This code is generated with http://github.com/hexdigest/gowrap tool
// using ../templates/grpc_validate template
//go:generate gowrap gen -p github.com/hexdigest/gowrap/templates_tests -i InterfaceWithValidtableArg -t ../templates/grpc_validate -o interface_with_grpc_validation.go
import (
"context"
grpc_codes "google.golang.org/grpc/codes"
grpc_status "google.golang.org/grpc/status"
)
// InterfaceWithValidtableArgWithGRPCValidation implements InterfaceWithValidtableArg interface instrumented with GRPC request validation
type InterfaceWithValidtableArgWithGRPCValidation struct {
InterfaceWithValidtableArg
}
// NewInterfaceWithValidtableArgWithGRPCValidation returns InterfaceWithValidtableArgWithGRPCValidation
func NewInterfaceWithValidtableArgWithGRPCValidation(base InterfaceWithValidtableArg) InterfaceWithValidtableArgWithGRPCValidation {
return InterfaceWithValidtableArgWithGRPCValidation{
InterfaceWithValidtableArg: base,
}
}
// Method implements InterfaceWithValidtableArg
func (_d InterfaceWithValidtableArgWithGRPCValidation) Method(ctx context.Context, r *ValidatableRequest) (err error) {
if _v, _ok := interface{}(r).(interface{ Validate() error }); _ok {
if err = _v.Validate(); err != nil {
err = grpc_status.Error(grpc_codes.InvalidArgument, err.Error())
return
}
}
return _d.InterfaceWithValidtableArg.Method(ctx, r)
}