serve

package
v0.0.0-...-b4aeae5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 14 Imported by: 0

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(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