feat: some refactoring
This commit is contained in:
37
internal/apiserver/handlers/home.go
Normal file
37
internal/apiserver/handlers/home.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user