chore(solution): pull lab2 solution

This commit is contained in:
2026-11-06 02:34:43 +03:00
parent 0ab3a341aa
commit de2f63b926
41 changed files with 2636 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package handler
import (
"context"
"log/slog"
"net/http"
"messenger/internal/service"
)
type Pinger func(ctx context.Context) error
type Handler struct {
users *service.UserService
auth *service.AuthService
chats *service.ChatService
messages *service.MessageService
deps []Pinger
log *slog.Logger
}
func New(users *service.UserService, auth *service.AuthService, chats *service.ChatService,
messages *service.MessageService, deps []Pinger, log *slog.Logger) *Handler {
return &Handler{users: users, auth: auth, chats: chats, messages: messages, deps: deps, log: log}
}
func (h *Handler) NotFound(w http.ResponseWriter, _ *http.Request) {
writeError(w, http.StatusNotFound, "not_found", "resource not found")
}
func (h *Handler) MethodNotAllowed(w http.ResponseWriter, _ *http.Request) {
writeError(w, http.StatusMethodNotAllowed, "invalid_request", "method not allowed")
}