This commit is contained in:
vipg
2026-02-09 17:04:20 +08:00
parent ec07824a4d
commit e9457b8a24
3 changed files with 34 additions and 1 deletions

View File

@@ -69,13 +69,25 @@ func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {
}
func (h *Handler) Healthz(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
httpx.MethodNotAllowed(w, string(codes.MethodNotAllowed))
return
}
httpx.OK(w, nil)
}
func (h *Handler) Version(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
httpx.MethodNotAllowed(w, string(codes.MethodNotAllowed))
return
}
httpx.OK(w, map[string]string{"version": "user-service v0.1.0"})
}
func (h *Handler) Root(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
httpx.MethodNotAllowed(w, string(codes.MethodNotAllowed))
return
}
httpx.OK(w, map[string]string{"service": "user"})
}

View File

@@ -12,6 +12,7 @@ import (
"common/db"
"common/logger"
"common/utils"
"common/httpx"
"user/internal/handler"
"user/internal/repository"
"user/internal/router"
@@ -64,7 +65,8 @@ func routes() http.Handler {
repo := repository.New(pg)
svc := service.New(repo)
h := handler.New(svc)
return router.New(h)
cors := httpx.CORS()
return cors(router.New(h))
}
func applySchema(path string) error {