serve

package
v1.52.3-0...-16af9ab Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2020 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 namedirfist/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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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