serve

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package serve deals with serving objects over HTTP

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(ctx context.Context, what interface{}, w http.ResponseWriter, text string, err error)

Error logs the error and if a ResponseWriter is given it writes an http.StatusInternalServerError

func Object

func Object(w http.ResponseWriter, r *http.Request, o fs.Object)

Object serves an fs.Object via HEAD or GET

Types

type Crumb

type Crumb struct {
	Link string
	Text string
}

Crumb is a breadcrumb entry

type DirEntry

type DirEntry struct {
	URL     string
	Leaf    string
	IsDir   bool
	Size    int64
	ModTime time.Time
	// contains filtered or unexported fields
}

DirEntry is a directory entry

type Directory

type Directory struct {
	DirRemote    string
	Title        string
	Name         string
	Entries      []DirEntry
	Query        string
	HTMLTemplate *template.Template
	Breadcrumb   []Crumb
	Sort         string
	Order        string
}

Directory represents a directory

func NewDirectory

func NewDirectory(dirRemote string, htmlTemplate *template.Template) *Directory

NewDirectory makes an empty Directory

func (*Directory) AddEntry

func (d *Directory) AddEntry(remote string, isDir bool)

AddEntry adds an entry to that directory

func (*Directory) AddHTMLEntry

func (d *Directory) AddHTMLEntry(remote string, isDir bool, size int64, modTime time.Time)

AddHTMLEntry adds an entry to that directory

func (*Directory) ProcessQueryParams

func (d *Directory) ProcessQueryParams(sortParm string, orderParm string) *Directory

ProcessQueryParams takes and sorts/orders based on the request sort/order parameters and default is namedirfirst/asc

func (*Directory) Serve

func (d *Directory) Serve(w http.ResponseWriter, r *http.Request)

Serve serves a directory

func (*Directory) SetQuery

func (d *Directory) SetQuery(queryParams url.Values) *Directory

SetQuery sets the query parameters for each URL

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL