lab4: S3-вложения, presigned upload и проверки
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user