Documentation / base / HttpDirectoryReader
Interface: HttpDirectoryReader
Defined in: libs/base/src/vfs/readers/reader.ts:71
Interface for an HTTP directory reader.
Implementations encapsulate the logic to enumerate entries under an HTTP-served directory. This may involve parsing HTML indexes, JSON manifests, or custom APIs.
Notes:
- A host VFS may register multiple readers and select one via HttpDirectoryReader.canHandle.
- Readers should return a flat list of entries for the provided
dirPathonly (non-recursive). Recursion is orchestrated by the VFS if needed.
Properties
name
readonlyname:string
Defined in: libs/base/src/vfs/readers/reader.ts:75
Human-readable name of this reader implementation (for diagnostics/logging).
Methods
canHandle()?
optionalcanHandle(dirPath,ctx):boolean|Promise<boolean>
Defined in: libs/base/src/vfs/readers/reader.ts:89
Optional probe that indicates whether this reader can handle the given directory.
Typical strategies:
- Check for a known index file (e.g., "index.json")
- HEAD/GET and inspect headers/content patterns
If omitted, the host may assume the reader can handle all directories.
Parameters
dirPath
string
Normalized directory path (typically ends with "/").
ctx
Context utilities for fetching and path handling.
Returns
boolean | Promise<boolean>
true if supported, otherwise false. May return a promise.
readOnce()
readOnce(
dirPath,ctx):Promise<FileMetadata[]>
Defined in: libs/base/src/vfs/readers/reader.ts:106
Performs a single-pass listing of the directory at dirPath.
Requirements:
- Return only direct children of
dirPath(non-recursive). - Populate
FileMetadatafields as accurately as possible (name, path, type, size, timestamps, mimeType). - Use
ctx.normalizePath/ctx.joinPathto build stablepathfields.
Error handling:
- Throw on unrecoverable errors (the host VFS may fall back to other readers).
- Return an empty array if the directory is valid but contains no entries.
Parameters
dirPath
string
Normalized directory path to read (typically ends with "/").
ctx
Context utilities for network and path operations.
Returns
Promise<FileMetadata[]>
A promise resolving to a flat list of file/directory metadata.