38 lines
927 B
Go
38 lines
927 B
Go
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)
|
|
}
|