Documentation
¶
Index ¶
- Variables
- type Browser
- func (b *Browser) List(dir string, hidden bool) (*ListResult, error)
- func (b *Browser) ServeRaw(w http.ResponseWriter, r *http.Request, path string) error
- func (b *Browser) ServeThumb(w http.ResponseWriter, r *http.Request, path string, size int) error
- func (b *Browser) ValidatePath(path string) error
- func (b *Browser) View(path string) (*FileView, error)
- type DirEntry
- type FileView
- type ListResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedFile = errors.New("unsupported file type") ErrFileTooLarge = errors.New("file too large") )
Sentinel errors for file browser operations.
Functions ¶
This section is empty.
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
func (*Browser) ServeRaw ¶
ServeRaw streams the file at path after expanding ~ and validating the resolved absolute path against the allowed roots. It does not write error responses itself: a pre-stream failure is returned as *thumbnail.HTTPError carrying the status/message the caller should deliver (in the server's JSON envelope). Returns nil once http.ServeFile has taken over the response.
func (*Browser) ServeThumb ¶ added in v0.101.0
ServeThumb serves a low-resolution JPEG thumbnail of the image at path. Path is validated against the allowed roots just like ServeRaw. Non-image extensions return 415 immediately so unsupported types don't hit the decoder. `size` is the requested longer-edge in pixels (clamped by the thumbnail package).
Like ServeRaw, ServeThumb does not write error responses itself: a pre-stream failure is returned as *thumbnail.HTTPError so the caller can deliver it in the server's JSON envelope. Returns nil once http.ServeFile has taken over the response.
func (*Browser) ValidatePath ¶ added in v0.5.0
ValidatePath checks that the given path is under an allowed root directory.