Files
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

2.0 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
upload_handler pipeline go infra 1.0.0 impure func UploadHandler(cfg StorageConfig) http.HandlerFunc HTTP handler completo para multipart upload. Compone UploadParse + FileValidateType + FileSaveDisk segun StorageConfig. Responde JSON con los UploadedFile guardados o un HTTPError estructurado en caso de fallo.
http
upload
multipart
handler
pipeline
infra
pendiente-usar
upload_parse_go_infra
file_validate_type_go_infra
file_save_disk_go_infra
http_json_response_go_infra
http_error_response_go_infra
StorageConfig_go_infra
UploadedFile_go_infra
HTTPError_go_infra
false error_go_core
net/http
name desc
cfg StorageConfig con BaseDir, MaxFileSize y AllowedTypes
http.HandlerFunc lista para montar como ruta. Responde 200 con {"files":[UploadedFile,...]}, 400 parse_error, 415 invalid_type o 500 save_error true
acepta upload con multiple imagenes y responde JSON
rechaza tipo no permitido con 415
rechaza body que excede MaxFileSize con 400
functions/infra/upload_handler_test.go functions/infra/upload_handler.go

Ejemplo

cfg := StorageConfig{
    BaseDir:      "./uploads",
    MaxFileSize:  10 << 20,
    AllowedTypes: []string{"image/png", "image/jpeg", "application/pdf"},
}

mux := HTTPRouter([]Route{
    {Method: "POST", Path: "/api/upload", Handler: UploadHandler(cfg)},
})
http.ListenAndServe(":8080", mux)

Notas

Pipeline de 5 funciones — compone parse + validate + save + json/error responses. El campo ContentType del UploadedFile retornado se sobreescribe con el MIME REAL detectado por magic bytes (ignorando el Content-Type del request), no con el inferido por extension.

Si un archivo del batch falla, el handler responde error y NO continua. Las funciones que ya se guardaron en disco quedan ahi (no hay rollback transaccional).