chores: refactor struct and structure project

This commit is contained in:
ericprd
2025-03-05 21:21:44 +08:00
parent 13a8481f22
commit 567e0e32ca
103 changed files with 1125 additions and 731 deletions
@@ -0,0 +1,23 @@
package response
import (
"errors"
"net/http"
)
func RespondWithError(w http.ResponseWriter, r *http.Request, err error, msg string) {
if err != nil {
code := ErrUnauthorized.Code
status := http.StatusUnauthorized
if errors.Is(err, ErrExpiryToken) {
code = ErrExpiryToken.Code
status = ErrExpiryToken.HttpCode
}
RespondJsonErrorWithCode(r.Context(), w, err, code, status, msg)
} else {
RespondJsonErrorWithCode(r.Context(), w, nil,
ErrUnauthorized.Code, http.StatusUnauthorized, msg)
}
}