Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add '/api' Prefix to All Routes to Resolve NGINX Route Conflict #20

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions http-req/content.http
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###
# SignIn endpoint
POST http://localhost:3030/signin
POST http://localhost:3030/api/signin
Content-Type: application/json

{
Expand All @@ -10,7 +10,7 @@ Content-Type: application/json

###
# Create Content 1
POST http://localhost:3030/course/advanced-golang/content
POST http://localhost:3030/api/course/advanced-golang/content
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -26,7 +26,7 @@ Content-Type: application/json

###
# Create Content 2
POST http://localhost:3030/course/advanced-golang/content
POST http://localhost:3030/api/course/advanced-golang/content
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -41,20 +41,20 @@ Content-Type: application/json

###
# Get
GET http://localhost:3030/course/advanced-golang/content/course-introduction
GET http://localhost:3030/api/course/advanced-golang/content/course-introduction
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json


###
# List
GET http://localhost:3030/course/advanced-golang/content/list
GET http://localhost:3030/api/course/advanced-golang/content/list
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json


###
# Get
DELETE http://localhost:3030/course/advanced-golang/content/refresher-lab-01
DELETE http://localhost:3030/api/course/advanced-golang/content/refresher-lab-01
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json
16 changes: 8 additions & 8 deletions http-req/course.http
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###
# SignIn endpoint
POST http://localhost:3030/signin
POST http://localhost:3030/api/signin
Content-Type: application/json

{
Expand All @@ -12,7 +12,7 @@ Content-Type: application/json

###
# Create Course 1
POST http://localhost:3030/course
POST http://localhost:3030/api/course
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -24,7 +24,7 @@ Content-Type: application/json

###
# Create Course 2
POST http://localhost:3030/course
POST http://localhost:3030/api/course
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -36,12 +36,12 @@ Content-Type: application/json

###
# Get Course
GET http://localhost:3030/course/prometheus-certified-associate-pca
GET http://localhost:3030/api/course/prometheus-certified-associate-pca
Authorization: Bearer {{PRAROMVIK}}

###
# Update Course
PUT http://localhost:3030/course/prometheus-certified-associate-pca
PUT http://localhost:3030/api/course/prometheus-certified-associate-pca
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -52,13 +52,13 @@ Content-Type: application/json

###
# Delete Course
DELETE http://localhost:3030/course/advanced-golang
DELETE http://localhost:3030/api/course/advanced-golang
Authorization: Bearer {{PRAROMVIK}}

###
# List Course
GET http://localhost:3030/course/list
GET http://localhost:3030/api/course/list
Authorization: Bearer {{PRAROMVIK}}


GET http://localhost:3030/course/advanced-golang/introduction/quiz-1/
GET http://localhost:3030/api/course/advanced-golang/introduction/quiz-1/
10 changes: 5 additions & 5 deletions http-req/lesson.http
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###
# SignIn endpoint
POST http://localhost:3030/signin
POST http://localhost:3030/api/signin
Content-Type: application/json

{
Expand All @@ -11,7 +11,7 @@ Content-Type: application/json

###
# Create Lesson 1
POST http://localhost:3030/course/advanced-golang/lesson
POST http://localhost:3030/api/course/advanced-golang/lesson
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -21,7 +21,7 @@ Content-Type: application/json

###
# Create Lesson 2
POST http://localhost:3030/course/advanced-golang/lesson
POST http://localhost:3030/api/course/advanced-golang/lesson
Authorization: Bearer {{PRAROMVIK}}
Content-Type: application/json

Expand All @@ -32,11 +32,11 @@ Content-Type: application/json

###
# Get Lesson 1
GET http://localhost:3030/course/advanced-golang/lesson/concurrency
GET http://localhost:3030/api/course/advanced-golang/lesson/concurrency
Authorization: Bearer {{PRAROMVIK}}


###
# List
GET http://localhost:3030/course/advanced-golang/lesson/list
GET http://localhost:3030/api/course/advanced-golang/lesson/list
Authorization: Bearer {{PRAROMVIK}}
10 changes: 5 additions & 5 deletions http-req/user.http
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Sign up endpoint
POST http://localhost:3030/signup
POST http://localhost:3030/api/signup
Content-Type: application/json

{
Expand All @@ -11,19 +11,19 @@ Content-Type: application/json

###
# SignIn endpoint
POST http://localhost:3030/signin
POST http://localhost:3030/api/signin
Content-Type: application/json

{
"userName": "admin",
"password": "itiswhatitis"
"userName": "student-1",
"password": "123"
}

> {% client.global.set("PRAROMVIK", response.body.json.token); %}


###
POST http://localhost:3030/user/upload
POST http://localhost:3030/api/user/upload
Content-Type: multipart/form-data

{
Expand Down
12 changes: 6 additions & 6 deletions routers/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ func LoadRoutes() *chi.Mux {
router.Group(func(r chi.Router) {
loadUserAuthRoutes(r)
})
router.With(middleware.AdminAccess).Post("/role", user.User{}.ProvideRoleToUser)
router.With(middleware.AdminAccess).Post("/api/role", user.User{}.ProvideRoleToUser)

router.Route("/course", loadCourseRoutes)
router.Route("/api/course", loadCourseRoutes)
return router
}
func loadUserAuthRoutes(r chi.Router) {
userHandler := &user.User{}
r.Post("/signup", userHandler.SignUp)
r.Post("/signin", userHandler.SignIn)
r.Delete("/signout", userHandler.SignOut)
r.With(middleware.SecurityMiddleware).Get("/user/{userName}", userHandler.Get)
r.Post("/api/signup", userHandler.SignUp)
r.Post("/api/signin", userHandler.SignIn)
r.Delete("/api/signout", userHandler.SignOut)
r.With(middleware.SecurityMiddleware).Get("/api/user/{userName}", userHandler.Get)
}

func loadCourseRoutes(r chi.Router) {
Expand Down
Loading