Skip to content

Commit c57ad9a

Browse files
committed
run both gin and grpc in parallel
1 parent 04a949d commit c57ad9a

File tree

5 files changed

+317
-5
lines changed

5 files changed

+317
-5
lines changed

.air.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ testdata_dir = "testdata"
33
tmp_dir = "tmp"
44

55
[build]
6-
bin = "tmp\\main.exe"
6+
bin = "./tmp/main.exe"
77
cmd = "go build -o ./tmp/main.exe ./cmd/server/main.go"
88
delay = 1000
99
exclude_dir = ["assets", "tmp", "vendor", "testdata"]

Golang_API.postman_collection.json

Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
{
2+
"info": {
3+
"_postman_id": "112e818d-eb80-4ac7-bd1f-181e32484495",
4+
"name": "Golang_API",
5+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
6+
"_exporter_id": "14791724"
7+
},
8+
"item": [
9+
{
10+
"name": "Auth",
11+
"item": [
12+
{
13+
"name": "Register",
14+
"request": {
15+
"method": "POST",
16+
"header": [],
17+
"body": {
18+
"mode": "raw",
19+
"raw": "{\r\n \"email\": \"admin@admin.com\",\r\n \"name\": \"Admin\",\r\n \"photo\": \"default.png\",\r\n \"password\": \"password123\",\r\n \"passwordConfirm\": \"password123\"\r\n}",
20+
"options": {
21+
"raw": {
22+
"language": "json"
23+
}
24+
}
25+
},
26+
"url": {
27+
"raw": "localhost:8000/api/auth/register",
28+
"host": [
29+
"localhost"
30+
],
31+
"port": "8000",
32+
"path": [
33+
"api",
34+
"auth",
35+
"register"
36+
]
37+
}
38+
},
39+
"response": []
40+
},
41+
{
42+
"name": "Refresh Token",
43+
"request": {
44+
"method": "GET",
45+
"header": [],
46+
"url": {
47+
"raw": "localhost:8000/api/auth/refresh",
48+
"host": [
49+
"localhost"
50+
],
51+
"port": "8000",
52+
"path": [
53+
"api",
54+
"auth",
55+
"refresh"
56+
]
57+
}
58+
},
59+
"response": []
60+
},
61+
{
62+
"name": "Logout",
63+
"request": {
64+
"method": "GET",
65+
"header": [],
66+
"url": {
67+
"raw": "localhost:8000/api/auth/logout",
68+
"host": [
69+
"localhost"
70+
],
71+
"port": "8000",
72+
"path": [
73+
"api",
74+
"auth",
75+
"logout"
76+
]
77+
}
78+
},
79+
"response": []
80+
},
81+
{
82+
"name": "Login",
83+
"request": {
84+
"method": "POST",
85+
"header": [],
86+
"body": {
87+
"mode": "raw",
88+
"raw": "{\r\n \"email\": \"admin@admin.com\",\r\n \"password\": \"password123\"\r\n}",
89+
"options": {
90+
"raw": {
91+
"language": "json"
92+
}
93+
}
94+
},
95+
"url": {
96+
"raw": "localhost:8000/api/auth/login",
97+
"host": [
98+
"localhost"
99+
],
100+
"port": "8000",
101+
"path": [
102+
"api",
103+
"auth",
104+
"login"
105+
]
106+
}
107+
},
108+
"response": []
109+
},
110+
{
111+
"name": "Verify Email Address",
112+
"request": {
113+
"method": "GET",
114+
"header": [],
115+
"url": {
116+
"raw": "{{host}}/api/auth/verifyemail/M3ypLxqQMEMgRgWHwxee",
117+
"host": [
118+
"{{host}}"
119+
],
120+
"path": [
121+
"api",
122+
"auth",
123+
"verifyemail",
124+
"M3ypLxqQMEMgRgWHwxee"
125+
]
126+
}
127+
},
128+
"response": []
129+
}
130+
]
131+
},
132+
{
133+
"name": "User",
134+
"item": [
135+
{
136+
"name": "Get Me",
137+
"request": {
138+
"method": "GET",
139+
"header": [],
140+
"url": {
141+
"raw": "localhost:8000/api/users/me",
142+
"host": [
143+
"localhost"
144+
],
145+
"port": "8000",
146+
"path": [
147+
"api",
148+
"users",
149+
"me"
150+
]
151+
}
152+
},
153+
"response": []
154+
}
155+
]
156+
},
157+
{
158+
"name": "Post",
159+
"item": [
160+
{
161+
"name": "Create Post",
162+
"request": {
163+
"method": "POST",
164+
"header": [],
165+
"body": {
166+
"mode": "raw",
167+
"raw": "{\r\n \"title\": \"My first Python FASTAPI app project\",\r\n \"category\": \"Python\",\r\n \"content\": \"My content haha My content haha\",\r\n \"image\": \"default.png\"\r\n}",
168+
"options": {
169+
"raw": {
170+
"language": "json"
171+
}
172+
}
173+
},
174+
"url": {
175+
"raw": "localhost:8000/api/posts",
176+
"host": [
177+
"localhost"
178+
],
179+
"port": "8000",
180+
"path": [
181+
"api",
182+
"posts"
183+
]
184+
}
185+
},
186+
"response": []
187+
},
188+
{
189+
"name": "Get Post",
190+
"request": {
191+
"method": "GET",
192+
"header": [],
193+
"url": {
194+
"raw": "localhost:8000/api/posts/328cd0be-eeac-4be4-b764-7d3dc95695b2",
195+
"host": [
196+
"localhost"
197+
],
198+
"port": "8000",
199+
"path": [
200+
"api",
201+
"posts",
202+
"328cd0be-eeac-4be4-b764-7d3dc95695b2"
203+
]
204+
}
205+
},
206+
"response": []
207+
},
208+
{
209+
"name": "Update Post",
210+
"request": {
211+
"method": "PATCH",
212+
"header": [],
213+
"body": {
214+
"mode": "raw",
215+
"raw": "{\r\n \"title\": \"Updated My first golang GORM app project\",\r\n \"category\": \"Golang\"\r\n}",
216+
"options": {
217+
"raw": {
218+
"language": "json"
219+
}
220+
}
221+
},
222+
"url": {
223+
"raw": "localhost:8000/api/posts/e891ac2e-5371-45e3-a0d4-781e8c365905",
224+
"host": [
225+
"localhost"
226+
],
227+
"port": "8000",
228+
"path": [
229+
"api",
230+
"posts",
231+
"e891ac2e-5371-45e3-a0d4-781e8c365905"
232+
]
233+
}
234+
},
235+
"response": []
236+
},
237+
{
238+
"name": "Delete Post",
239+
"request": {
240+
"method": "DELETE",
241+
"header": [],
242+
"url": {
243+
"raw": "localhost:8000/api/posts/66e1374e-d1f5-4e70-ad61-1a014ba8309b",
244+
"host": [
245+
"localhost"
246+
],
247+
"port": "8000",
248+
"path": [
249+
"api",
250+
"posts",
251+
"66e1374e-d1f5-4e70-ad61-1a014ba8309b"
252+
]
253+
}
254+
},
255+
"response": []
256+
},
257+
{
258+
"name": "Get All Posts",
259+
"request": {
260+
"method": "GET",
261+
"header": [],
262+
"url": {
263+
"raw": "localhost:8000/api/posts?page=1&limit=10",
264+
"host": [
265+
"localhost"
266+
],
267+
"port": "8000",
268+
"path": [
269+
"api",
270+
"posts"
271+
],
272+
"query": [
273+
{
274+
"key": "page",
275+
"value": "1"
276+
},
277+
{
278+
"key": "limit",
279+
"value": "10"
280+
}
281+
]
282+
}
283+
},
284+
"response": []
285+
},
286+
{
287+
"name": "Health Checker",
288+
"request": {
289+
"method": "GET",
290+
"header": [],
291+
"url": {
292+
"raw": "http://localhost:8000/api/healthchecker",
293+
"protocol": "http",
294+
"host": [
295+
"localhost"
296+
],
297+
"port": "8000",
298+
"path": [
299+
"api",
300+
"healthchecker"
301+
]
302+
}
303+
},
304+
"response": []
305+
}
306+
]
307+
}
308+
]
309+
}

cmd/client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func main() {
7171
}
7272

7373
// Create Post
74-
if false {
74+
if true {
7575
createPostClient := client.NewCreatePostClient(conn)
7676

7777
args := &pb.CreatePostRequest{

cmd/server/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,12 @@ func main() {
111111

112112
defer mongoclient.Disconnect(ctx)
113113

114-
// startGinServer(config)
115-
startGrpcServer(config)
114+
// Start gRPC server in a separate goroutine
115+
go startGrpcServer(config)
116+
117+
// Start Gin server in the main goroutine
118+
startGinServer(config)
119+
116120
}
117121

118122
func startGrpcServer(config config.Config) {

tmp/build-errors.log

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)