/
converters.microgen.go
175 lines (143 loc) · 5.94 KB
/
converters.microgen.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
// Code generated by microgen 1.0.0-beta. DO NOT EDIT.
// Please, do not change functions names!
package transporthttp
import (
"bytes"
"context"
"encoding/json"
transport "github.com/devimteam/microgen/examples/usersvc/pkg/transport"
"io/ioutil"
"net/http"
"path"
)
func CommonHTTPRequestEncoder(_ context.Context, r *http.Request, request interface{}) error {
var buf bytes.Buffer
if err := json.NewEncoder(&buf).Encode(request); err != nil {
return err
}
r.Body = ioutil.NopCloser(&buf)
return nil
}
func CommonHTTPResponseEncoder(_ context.Context, w http.ResponseWriter, response interface{}) error {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
return json.NewEncoder(w).Encode(response)
}
func _Decode_CreateUser_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.CreateUserRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_UpdateUser_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.UpdateUserRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_GetUser_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.GetUserRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_FindUsers_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.FindUsersRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_CreateComment_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.CreateCommentRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_GetComment_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.GetCommentRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_GetUserComments_Request(_ context.Context, r *http.Request) (interface{}, error) {
var req transport.GetUserCommentsRequest
err := json.NewDecoder(r.Body).Decode(&req)
return &req, err
}
func _Decode_CreateUser_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.CreateUserResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Decode_UpdateUser_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.UpdateUserResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Decode_GetUser_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.GetUserResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Decode_FindUsers_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.FindUsersResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Decode_CreateComment_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.CreateCommentResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Decode_GetComment_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.GetCommentResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Decode_GetUserComments_Response(_ context.Context, r *http.Response) (interface{}, error) {
var resp transport.GetUserCommentsResponse
err := json.NewDecoder(r.Body).Decode(&resp)
return &resp, err
}
func _Encode_CreateUser_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "create-user")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_UpdateUser_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "update-user")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_GetUser_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "get-user")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_FindUsers_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "find-users")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_CreateComment_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "create-comment")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_GetComment_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "get-comment")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_GetUserComments_Request(ctx context.Context, r *http.Request, request interface{}) error {
r.URL.Path = path.Join(r.URL.Path, "get-user-comments")
return CommonHTTPRequestEncoder(ctx, r, request)
}
func _Encode_CreateUser_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}
func _Encode_UpdateUser_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}
func _Encode_GetUser_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}
func _Encode_FindUsers_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}
func _Encode_CreateComment_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}
func _Encode_GetComment_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}
func _Encode_GetUserComments_Response(ctx context.Context, w http.ResponseWriter, response interface{}) error {
return CommonHTTPResponseEncoder(ctx, w, response)
}