bc18d02935
new file: bin/api_yal new file: cmd/main.go new file: go.mod new file: internal/handlers/auth.go new file: internal/server/server.go add server, files, dockerfile, build
31 lines
867 B
Go
31 lines
867 B
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
// AuthHandler обработчик для аутентификации
|
|
type AuthHandler struct{}
|
|
|
|
// NewAuthHandler создает новый экземпляр AuthHandler
|
|
func NewAuthHandler() *AuthHandler {
|
|
return &AuthHandler{}
|
|
}
|
|
|
|
// HandleAuth обрабатывает GET запросы на /auth
|
|
func (h *AuthHandler) HandleAuth(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
|
|
// Возвращаем статус 200 OK
|
|
w.WriteHeader(http.StatusOK)
|
|
w.Write([]byte("OK"))
|
|
}
|
|
|
|
// RegisterAuthRoutes регистрирует маршруты для аутентификации
|
|
func RegisterAuthRoutes(mux *http.ServeMux) {
|
|
authHandler := NewAuthHandler()
|
|
mux.HandleFunc("/auth", authHandler.HandleAuth)
|
|
} |