Skip to content

Commit

Permalink
add /api/ the root of apis
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza-fa committed Feb 18, 2024
1 parent 067d765 commit dd928cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func InitialServer(logger logging.Logger) {

router.Use(middlewares.LogMiddleware)

Routers(router)
router.Route("/api/", Routers)

RegisterSwagger(router, logger)

Expand All @@ -35,7 +35,7 @@ func InitialServer(logger logging.Logger) {
}

func Routers(router chi.Router) {
routers.UserRouters(router)
router.Route("/users/", routers.UserRouters)
}

func RegisterSwagger(router chi.Router, logger logging.Logger) {
Expand Down
13 changes: 1 addition & 12 deletions src/api/handlers/user_front.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,7 @@ func NewUserFrontHandler() *UserFrontHandler {
}
}

func (handler *UserFrontHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch {
case r.Method == http.MethodPost && r.URL.Path == "/users/register/":
handler.UserRegister(w, r)
case r.Method == http.MethodPost && r.URL.Path == "/users/verify/":
handler.UserVerify(w, r)
case r.Method == http.MethodPost && r.URL.Path == "/users/login/":
handler.UserLogin(w, r)
default:
helper.BaseResponse(w, "", http.StatusMethodNotAllowed)
}
}
func (handler *UserFrontHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {}

// UserRegister godoc
// @Summary Send otp to user
Expand Down
6 changes: 3 additions & 3 deletions src/api/routers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func UserRouters(router chi.Router) {
handler := handlers.NewUserFrontHandler()

router.Post("/users/register/", handler.UserRegister)
router.Post("/users/verify/", handler.UserVerify)
router.Post("/users/login/", handler.UserLogin)
router.Post("/register/", handler.UserRegister)
router.Post("/verify/", handler.UserVerify)
router.Post("/login/", handler.UserLogin)
}

0 comments on commit dd928cd

Please sign in to comment.