This repository has been archived by the owner on Aug 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
project_http.pb.go
executable file
·198 lines (180 loc) · 6.63 KB
/
project_http.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// - protoc-gen-go-http v2.6.3
// - protoc v3.12.4
// source: project/v1/project.proto
package v1
import (
context "context"
http "github.com/go-kratos/kratos/v2/transport/http"
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the kratos package it is being compiled against.
var _ = new(context.Context)
var _ = binding.EncodeURL
const _ = http.SupportPackageIsVersion1
const OperationProjectDeleteProject = "/api.project.v1.Project/DeleteProject"
const OperationProjectGetProject = "/api.project.v1.Project/GetProject"
const OperationProjectListProjects = "/api.project.v1.Project/ListProjects"
const OperationProjectSaveProject = "/api.project.v1.Project/SaveProject"
type ProjectHTTPServer interface {
DeleteProject(context.Context, *DeleteRequest) (*DeleteReply, error)
GetProject(context.Context, *GetRequest) (*GetReply, error)
ListProjects(context.Context, *ListsRequest) (*ListsReply, error)
SaveProject(context.Context, *SaveRequest) (*SaveReply, error)
}
func RegisterProjectHTTPServer(s *http.Server, srv ProjectHTTPServer) {
r := s.Route("/")
r.GET("/api/v1/products/{product_name}/projects/{project_name}", _Project_GetProject0_HTTP_Handler(srv))
r.GET("/api/v1/products/{product_name}/projects", _Project_ListProjects0_HTTP_Handler(srv))
r.POST("/api/v1/products/{product_name}/projects/{project_name}", _Project_SaveProject0_HTTP_Handler(srv))
r.DELETE("/api/v1/products/{product_name}/projects/{project_name}", _Project_DeleteProject0_HTTP_Handler(srv))
}
func _Project_GetProject0_HTTP_Handler(srv ProjectHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in GetRequest
if err := ctx.BindQuery(&in); err != nil {
return err
}
if err := ctx.BindVars(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationProjectGetProject)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.GetProject(ctx, req.(*GetRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*GetReply)
return ctx.Result(200, reply)
}
}
func _Project_ListProjects0_HTTP_Handler(srv ProjectHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in ListsRequest
if err := ctx.BindQuery(&in); err != nil {
return err
}
if err := ctx.BindVars(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationProjectListProjects)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.ListProjects(ctx, req.(*ListsRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*ListsReply)
return ctx.Result(200, reply)
}
}
func _Project_SaveProject0_HTTP_Handler(srv ProjectHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in SaveRequest
if err := ctx.Bind(&in.Body); err != nil {
return err
}
if err := ctx.BindQuery(&in); err != nil {
return err
}
if err := ctx.BindVars(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationProjectSaveProject)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.SaveProject(ctx, req.(*SaveRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*SaveReply)
return ctx.Result(200, reply)
}
}
func _Project_DeleteProject0_HTTP_Handler(srv ProjectHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in DeleteRequest
if err := ctx.BindQuery(&in); err != nil {
return err
}
if err := ctx.BindVars(&in); err != nil {
return err
}
http.SetOperation(ctx, OperationProjectDeleteProject)
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.DeleteProject(ctx, req.(*DeleteRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*DeleteReply)
return ctx.Result(200, reply)
}
}
type ProjectHTTPClient interface {
DeleteProject(ctx context.Context, req *DeleteRequest, opts ...http.CallOption) (rsp *DeleteReply, err error)
GetProject(ctx context.Context, req *GetRequest, opts ...http.CallOption) (rsp *GetReply, err error)
ListProjects(ctx context.Context, req *ListsRequest, opts ...http.CallOption) (rsp *ListsReply, err error)
SaveProject(ctx context.Context, req *SaveRequest, opts ...http.CallOption) (rsp *SaveReply, err error)
}
type ProjectHTTPClientImpl struct {
cc *http.Client
}
func NewProjectHTTPClient(client *http.Client) ProjectHTTPClient {
return &ProjectHTTPClientImpl{client}
}
func (c *ProjectHTTPClientImpl) DeleteProject(ctx context.Context, in *DeleteRequest, opts ...http.CallOption) (*DeleteReply, error) {
var out DeleteReply
pattern := "/api/v1/products/{product_name}/projects/{project_name}"
path := binding.EncodeURL(pattern, in, true)
opts = append(opts, http.Operation(OperationProjectDeleteProject))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}
func (c *ProjectHTTPClientImpl) GetProject(ctx context.Context, in *GetRequest, opts ...http.CallOption) (*GetReply, error) {
var out GetReply
pattern := "/api/v1/products/{product_name}/projects/{project_name}"
path := binding.EncodeURL(pattern, in, true)
opts = append(opts, http.Operation(OperationProjectGetProject))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}
func (c *ProjectHTTPClientImpl) ListProjects(ctx context.Context, in *ListsRequest, opts ...http.CallOption) (*ListsReply, error) {
var out ListsReply
pattern := "/api/v1/products/{product_name}/projects"
path := binding.EncodeURL(pattern, in, true)
opts = append(opts, http.Operation(OperationProjectListProjects))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}
func (c *ProjectHTTPClientImpl) SaveProject(ctx context.Context, in *SaveRequest, opts ...http.CallOption) (*SaveReply, error) {
var out SaveReply
pattern := "/api/v1/products/{product_name}/projects/{project_name}"
path := binding.EncodeURL(pattern, in, false)
opts = append(opts, http.Operation(OperationProjectSaveProject))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "POST", path, in.Body, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}