...
1 package abe
2
3 import (
4 pbexamplepb "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb"
5 pbpathenum "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/pathenum"
6 "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
7 )
8
9
10 func (e ExamplepbNumericEnum) String() string {
11 return pbexamplepb.NumericEnum_ONE.String()
12 }
13
14
15
16 func (e ExamplepbNumericEnum) UnmarshalJSON(b []byte) error {
17 return unmarshalJSONEnum(b, pbexamplepb.NumericEnum_value)
18 }
19
20
21 func (e MessagePathEnumNestedPathEnum) String() string {
22 return pbpathenum.MessagePathEnum_JKL.String()
23 }
24
25
26
27 func (e MessagePathEnumNestedPathEnum) UnmarshalJSON(b []byte) error {
28 return unmarshalJSONEnum(b, pbpathenum.MessagePathEnum_NestedPathEnum_value)
29 }
30
31
32 func (e PathenumPathEnum) String() string {
33 return pbpathenum.PathEnum_DEF.String()
34 }
35
36
37
38 func (e PathenumPathEnum) UnmarshalJSON(b []byte) error {
39 return unmarshalJSONEnum(b, pbpathenum.PathEnum_value)
40 }
41
42 func unmarshalJSONEnum(b []byte, enumValMap map[string]int32) error {
43 val := string(b[1 : len(b)-1])
44 _, err := runtime.Enum(val, enumValMap)
45 return err
46 }
47
View as plain text