-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_gors.pb.go
147 lines (135 loc) · 5.11 KB
/
message_gors.pb.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Copyright 2020 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by protoc-gen-gors. DO NOT EDIT.
// versions:
// - protoc-gen-gors v1.3.0
// - protoc v4.24.3
// source: example/api/tests/jsonoptions/message.proto
package jsonoptions
import (
context "context"
gin "github.com/gin-gonic/gin"
gors "github.com/go-leo/gors"
binding "github.com/go-leo/gors/pkg/binding"
)
func MessagingServiceRoutes(svc MessagingService, opts ...gors.Option) []gors.Route {
options := gors.NewOptions(opts...)
wrapper := &_MessagingServiceWrapper{svc: svc, options: options}
_ = wrapper
return []gors.Route{
gors.NewRoute("POST", "/v1/messages/:message_id", _Messaging_CreateMessage_GORS_Handler(wrapper, options, _Messaging_CreateMessage_GORS_Handler_POST_71b8052a59ef2e1e6bb26f276891271b_Binding())),
gors.NewRoute("PATCH", "/v1/messages/:message_id", _Messaging_UpdateMessage_GORS_Handler(wrapper, options, _Messaging_UpdateMessage_GORS_Handler_PATCH_71b8052a59ef2e1e6bb26f276891271b_Binding())),
}
}
// MessagingService is the service API for Messaging service.
type MessagingService interface {
CreateMessage(context.Context, *Message) (*Message, error)
UpdateMessage(context.Context, *Message2) (*Message2, error)
}
var _ MessagingService = (*_MessagingServiceWrapper)(nil)
type _MessagingServiceWrapper struct {
svc MessagingService
options *gors.Options
}
func (wrapper *_MessagingServiceWrapper) CreateMessage(ctx context.Context, request *Message) (*Message, error) {
return wrapper.svc.CreateMessage(ctx, request)
}
func (wrapper *_MessagingServiceWrapper) UpdateMessage(ctx context.Context, request *Message2) (*Message2, error) {
return wrapper.svc.UpdateMessage(ctx, request)
}
func _Messaging_CreateMessage_GORS_Handler(svc MessagingService, options *gors.Options, binding *binding.HttpRuleBinding) func(c *gin.Context) {
return func(c *gin.Context) {
var rpcMethodName = "/tests.jsonnames.message.v1.Messaging/CreateMessage"
var ctx = gors.NewContext(c, rpcMethodName)
var req *Message
var resp *Message
var err error
req = new(Message)
if err = gors.RequestBind(
ctx, req, options.Tag,
gors.HttpRuleBinding(binding),
); err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
if ctx, err = gors.NewGRPCContext(ctx, options.IncomingHeaderMatcher, options.MetadataAnnotators); err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
resp, err = svc.CreateMessage(ctx, req)
if err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
gors.ResponseRender(ctx, gors.StatusCode(ctx), resp, "", gors.ProtoJSONRender(options.ProtoJSONMarshalOptions), options.ResponseWrapper)
}
}
func _Messaging_UpdateMessage_GORS_Handler(svc MessagingService, options *gors.Options, binding *binding.HttpRuleBinding) func(c *gin.Context) {
return func(c *gin.Context) {
var rpcMethodName = "/tests.jsonnames.message.v1.Messaging/UpdateMessage"
var ctx = gors.NewContext(c, rpcMethodName)
var req *Message2
var resp *Message2
var err error
req = new(Message2)
if err = gors.RequestBind(
ctx, req, options.Tag,
gors.HttpRuleBinding(binding),
); err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
if ctx, err = gors.NewGRPCContext(ctx, options.IncomingHeaderMatcher, options.MetadataAnnotators); err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
resp, err = svc.UpdateMessage(ctx, req)
if err != nil {
gors.ErrorRender(ctx, err, options.ErrorHandler, options.ResponseWrapper)
return
}
gors.ResponseRender(ctx, gors.StatusCode(ctx), resp, "", gors.ProtoJSONRender(options.ProtoJSONMarshalOptions), options.ResponseWrapper)
}
}
func _Messaging_CreateMessage_GORS_Handler_POST_71b8052a59ef2e1e6bb26f276891271b_Binding() *binding.HttpRuleBinding {
return &binding.HttpRuleBinding{
Path: []*binding.PathRule{
{Name: "message_id", Type: "string"},
},
Query: []*binding.QueryRule{
// typ:string
{Name: "not_used", Type: "string", ItemType: ""},
},
Body: &binding.BodyRule{
Name: "body_text",
Type: "string",
},
}
}
func _Messaging_UpdateMessage_GORS_Handler_PATCH_71b8052a59ef2e1e6bb26f276891271b_Binding() *binding.HttpRuleBinding {
return &binding.HttpRuleBinding{
Path: []*binding.PathRule{
{Name: "message_id", Type: "string"},
},
Query: []*binding.QueryRule{
// typ:string
{Name: "not_used", Type: "string", ItemType: ""},
},
Body: &binding.BodyRule{
Name: "body_text",
Type: "string",
},
}
}