lab4: S3-вложения, presigned upload и проверки

This commit is contained in:
Vladislav Kunetskiy
2026-10-21 22:42:48 +03:00
parent d342b2a227
commit 49c2fe3071
79 changed files with 12266 additions and 910 deletions
+15 -2
View File
@@ -10,8 +10,9 @@ import (
func NewRouter(
handler oas.Handler,
security oas.SecurityHandler,
extensions *Extensions,
log *slog.Logger,
maxBodyBytes int64,
maxBodyBytes, maxUploadBytes int64,
) (http.Handler, error) {
server, err := oas.NewServer(
handler,
@@ -25,7 +26,19 @@ func NewRouter(
return nil, err
}
mux := http.NewServeMux()
if extensions != nil {
// These routes are an optional contract extension (presigned uploads).
// They live outside the generated server so contracts/openapi.json stays
// byte-identical to the mandatory contract.
mux.Handle("/api/v1/chats/{chat_id}/attachments/presign", extensions.Presign())
mux.Handle("/api/v1/attachments/{attachment_id}/complete", extensions.Complete())
}
mux.Handle("/", server)
return requestIDMiddleware(
instanceIDMiddleware(InstanceID(), bodyLimitMiddleware(maxBodyBytes, log, server)),
instanceIDMiddleware(InstanceID(), bodyLimitMiddleware(maxBodyBytes, maxUploadBytes, log, mux)),
), nil
}