feat: some refactoring

This commit is contained in:
2025-11-22 22:23:49 +03:00
parent a247e6213e
commit 51f30b516e
29 changed files with 1094 additions and 129 deletions

View File

@@ -0,0 +1,37 @@
package handlers
import (
"encoding/json"
"net/http"
"git.nwaifu.su/sergey/MyGoServer/internal/apiserver/models"
)
// HomeHandler handles the root endpoint
type HomeHandler struct{}
func NewHomeHandler() *HomeHandler {
return &HomeHandler{}
}
// ServeHTTP implements http.Handler
func (h *HomeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
h.handleHome(w, r)
}
// @Summary Health check
// @Description Проверка состояния сервера
// @Tags Health
// @Success 200 {object} models.Response "Server is running"
// @Router / [get]
func (h *HomeHandler) handleHome(w http.ResponseWriter, r *http.Request) {
// Create a simple success response
response := models.NewSuccessResponse(map[string]string{
"status": "ok",
"message": "API Server is running",
})
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(response)
}