47fac22230
- .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>
2.0 KiB
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. |
|
|
|
false | error_go_core |
|
|
http.HandlerFunc lista para montar como ruta. Responde 200 con {"files":[UploadedFile,...]}, 400 parse_error, 415 invalid_type o 500 save_error | true |
|
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).