Skip to content

Commit 8a76e70

Browse files
Remove routeV1
1 parent 2c7f8c2 commit 8a76e70

File tree

9 files changed

+39
-42
lines changed

9 files changed

+39
-42
lines changed

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,12 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
135135
│ ├── middleware
136136
│ │ └── jwt_auth_middleware.go
137137
│ └── route
138-
│ └── v1
139-
│ ├── login_route.go
140-
│ ├── profile_route.go
141-
│ ├── refresh_token_route.go
142-
│ ├── route.go
143-
│ ├── signup_route.go
144-
│ └── task_route.go
138+
│ ├── login_route.go
139+
│ ├── profile_route.go
140+
│ ├── refresh_token_route.go
141+
│ ├── route.go
142+
│ ├── signup_route.go
143+
│ └── task_route.go
145144
├── bootstrap
146145
│ ├── app.go
147146
│ ├── database.go
@@ -192,7 +191,7 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
192191
- Request
193192

194193
```
195-
curl --location --request POST 'http://localhost:8080/v1/signup' \
194+
curl --location --request POST 'http://localhost:8080/signup' \
196195
--data-urlencode '[email protected]' \
197196
--data-urlencode 'password=test' \
198197
--data-urlencode 'name=Test Name'
@@ -212,7 +211,7 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
212211
- Request
213212

214213
```
215-
curl --location --request POST 'http://localhost:8080/v1/login' \
214+
curl --location --request POST 'http://localhost:8080/login' \
216215
--data-urlencode '[email protected]' \
217216
--data-urlencode 'password=test'
218217
```
@@ -231,7 +230,7 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
231230
- Request
232231

233232
```
234-
curl --location --request GET 'http://localhost:8080/v1/profile' \
233+
curl --location --request GET 'http://localhost:8080/profile' \
235234
--header 'Authorization: Bearer access_token'
236235
```
237236

@@ -249,7 +248,7 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
249248
- Request
250249

251250
```
252-
curl --location --request POST 'http://localhost:8080/v1/task' \
251+
curl --location --request POST 'http://localhost:8080/task' \
253252
--header 'Authorization: Bearer access_token' \
254253
--header 'Content-Type: application/x-www-form-urlencoded' \
255254
--data-urlencode 'title=Test Task'
@@ -268,7 +267,7 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
268267
- Request
269268

270269
```
271-
curl --location --request GET 'http://localhost:8080/v1/task' \
270+
curl --location --request GET 'http://localhost:8080/task' \
272271
--header 'Authorization: Bearer access_token'
273272
```
274273

@@ -290,7 +289,7 @@ Whenever you make changes in the interfaces of these use-cases, repositories, or
290289
- Request
291290

292291
```
293-
curl --location --request POST 'http://localhost:8080/v1/refresh' \
292+
curl --location --request POST 'http://localhost:8080/refresh' \
294293
--header 'Content-Type: application/x-www-form-urlencoded' \
295294
--data-urlencode 'refreshToken=refresh_token'
296295
```
File renamed without changes.
File renamed without changes.
File renamed without changes.

api/route/route.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package route
2+
3+
import (
4+
"time"
5+
6+
"github.com/amitshekhariitbhu/go-backend-clean-architecture/api/middleware"
7+
"github.com/amitshekhariitbhu/go-backend-clean-architecture/bootstrap"
8+
"github.com/amitshekhariitbhu/go-backend-clean-architecture/mongo"
9+
"github.com/gin-gonic/gin"
10+
)
11+
12+
func Setup(env *bootstrap.Env, timeout time.Duration, db mongo.Database, gin *gin.Engine) {
13+
publicRouter := gin.Group("")
14+
// All Public APIs
15+
NewSignupRouter(env, timeout, db, publicRouter)
16+
NewLoginRouter(env, timeout, db, publicRouter)
17+
NewRefreshTokenRouter(env, timeout, db, publicRouter)
18+
19+
protectedRouter := gin.Group("")
20+
// Middleware to verify AccessToken
21+
protectedRouter.Use(middleware.JwtAuthMiddleware(env.AccessTokenSecret))
22+
// All Private APIs
23+
NewProfileRouter(env, timeout, db, protectedRouter)
24+
NewTaskRouter(env, timeout, db, protectedRouter)
25+
}
File renamed without changes.
File renamed without changes.

api/route/v1/route.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

cmd/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"time"
55

6-
routeV1 "github.com/amitshekhariitbhu/go-backend-clean-architecture/api/route/v1"
6+
route "github.com/amitshekhariitbhu/go-backend-clean-architecture/api/route"
77
"github.com/amitshekhariitbhu/go-backend-clean-architecture/bootstrap"
88
"github.com/gin-gonic/gin"
99
)
@@ -21,9 +21,7 @@ func main() {
2121

2222
gin := gin.Default()
2323

24-
routerV1 := gin.Group("v1")
25-
26-
routeV1.Setup(env, timeout, db, routerV1)
24+
route.Setup(env, timeout, db, gin)
2725

2826
gin.Run(env.ServerAddress)
2927
}

0 commit comments

Comments
 (0)