modified: Dockerfile
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
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// NewServer создает новый HTTP сервер
|
||||
func NewServer(addr string, handler http.Handler) *http.Server {
|
||||
return &http.Server{
|
||||
Addr: addr,
|
||||
Handler: handler,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user