first commit

This commit is contained in:
2026-02-22 00:15:25 +07:00
commit 39fc9e9e3f
25 changed files with 2116 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package handler
import (
"net/http"
"ristek-task-be/internal/db/sqlc/repository"
"ristek-task-be/internal/jwt"
)
type Handler struct {
repository *repository.Queries
jwt *jwt.JWT
}
func New(repository *repository.Queries, jwt *jwt.JWT) *Handler {
return &Handler{
repository: repository,
jwt: jwt,
}
}
func badRequest(w http.ResponseWriter, err error) {
w.WriteHeader(http.StatusBadRequest)
_, _ = w.Write([]byte(err.Error()))
}
func unauthorized(w http.ResponseWriter) {
w.WriteHeader(http.StatusUnauthorized)
}
func internalServerError(w http.ResponseWriter, err error) {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte(err.Error()))
}
func (h *Handler) HealthGet(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("OK"))
}