| file_serve |
function |
go |
infra |
1.0.0 |
impure |
func FileServe(dir string, pathPrefix string, maxAge int) http.Handler |
Retorna un http.Handler que sirve archivos estaticos desde dir, stripeando pathPrefix del URL. Setea Cache-Control con max-age. Rechaza paths con "..". |
| http |
| file |
| serve |
| static |
| cache |
| security |
| infra |
|
|
|
|
false |
error_go_core |
|
| name |
desc |
| dir |
directorio raiz desde donde se sirven los archivos |
|
| name |
desc |
| pathPrefix |
prefijo del URL a remover antes de buscar (ej: "/files/") |
|
| name |
desc |
| maxAge |
segundos para el header Cache-Control max-age |
|
|
http.Handler listo para registrar en un mux. No retorna error directo; el handler responde 400 si detecta path traversal y delega al http.FileServer en otros casos |
true |
| sirve archivo existente con headers de cache |
| responde 404 para archivo inexistente |
| rechaza path con .. con 400 |
|
functions/infra/file_serve_test.go |
functions/infra/file_serve.go |