Documentation
¶
Overview ¶
Package serve deals with serving objects over HTTP
Index ¶
- func Error(ctx context.Context, what any, w http.ResponseWriter, text string, err error)
- func Object(w http.ResponseWriter, r *http.Request, o fs.Object)
- type Crumb
- type DirEntry
- type Directory
- func (d *Directory) AddEntry(remote string, isDir bool)
- func (d *Directory) AddHTMLEntry(remote string, isDir bool, size int64, modTime time.Time)
- func (d *Directory) IsRoot() bool
- func (d *Directory) NumDirs() (n int)
- func (d *Directory) NumFiles() int
- func (d *Directory) Path() string
- func (d *Directory) ProcessQueryParams(sortParm string, orderParm string) *Directory
- func (d *Directory) Render(w io.Writer) error
- func (d *Directory) Serve(w http.ResponseWriter, r *http.Request)
- func (d *Directory) SetLinkIndex(name string) *Directory
- func (d *Directory) SetQuery(queryParams url.Values) *Directory
- func (d *Directory) TotalSize() (size int64)
- func (d *Directory) UpLink() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DirEntry ¶
type DirEntry struct {
URL string
ZipURL string
Leaf string
IsDir bool
Size int64
ModTime time.Time
MimeType string
// contains filtered or unexported fields
}
DirEntry is a directory entry
type Directory ¶
type Directory struct {
DirRemote string
Title string
Name string
ZipURL string
DisableZip bool
Entries []DirEntry
Query string
HTMLTemplate *template.Template
Breadcrumb []Crumb
Sort string
Order string
Static bool // rendering for a static site, so no "up" link at the root
LinkIndex string // if set, appended to directory links, e.g. "index.html"
}
Directory represents a directory
func NewDirectory ¶
NewDirectory makes an empty Directory
func (*Directory) AddHTMLEntry ¶
AddHTMLEntry adds an entry to that directory
func (*Directory) Path ¶ added in v1.76.0
Path returns the path of the directory from the root with leading and trailing slashes, e.g. "/dir/" or "/" for the root.
func (*Directory) ProcessQueryParams ¶
ProcessQueryParams takes and sorts/orders based on the request sort/order parameters and default is namedirfirst/asc
func (*Directory) Render ¶ added in v1.76.0
Render writes the directory listing to w using the HTML template
func (*Directory) Serve ¶
func (d *Directory) Serve(w http.ResponseWriter, r *http.Request)
Serve serves a directory
func (*Directory) SetLinkIndex ¶ added in v1.76.0
SetLinkIndex makes directory links point at name inside the directory, e.g. "dir/index.html" rather than "dir/", for hosts which don't serve index documents. Call it before adding entries.