fs

package
v0.0.0-...-3d9cc79 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

HTTP requests and responses that work with files on the server's file system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRoute

func NewRoute(contentRootPath string) http.Route

Types

type DirectoryListing

type DirectoryListing struct {
	Files      []string
	HrefPrefix string
	// contains filtered or unexported fields
}

Responds with a navigable list of files and directories in a given path

func (*DirectoryListing) Get

func (listing *DirectoryListing) Get(client io.Writer, message http.RequestMessage)

func (*DirectoryListing) Head

func (listing *DirectoryListing) Head(client io.Writer, message http.RequestMessage)

func (*DirectoryListing) Name

func (listing *DirectoryListing) Name() string

type FileSlice

type FileSlice interface {
	WriteStatus(writer io.Writer)
	WriteContentHeaders(writer io.Writer)
	WriteBody(writer io.Writer)
}

A view of all/part of a file

func ParseByteRange

func ParseByteRange(byteRangeSpecifier string, filename string, contentType string) FileSlice

type FileSystemRoute

type FileSystemRoute struct {
	ContentRootPath string
	Factory         ResourceFactory
}

func (FileSystemRoute) Route

func (route FileSystemRoute) Route(requested http.RequestMessage) http.Request

type LocalResources

type LocalResources struct{}

Factory for Resources in this package

func (*LocalResources) DirectoryListingResource

func (*LocalResources) DirectoryListingResource(message http.RequestMessage, files []string) http.Resource

func (*LocalResources) ExistingFileResource

func (*LocalResources) ExistingFileResource(message http.RequestMessage, path string) http.Resource

func (*LocalResources) NonExistingResource

func (*LocalResources) NonExistingResource(message http.RequestMessage) http.Resource

type NonExisting

type NonExisting struct {
	Path string
	// contains filtered or unexported fields
}

A requested file or directory that does not exist at the requested path

func (*NonExisting) Get

func (nonExisting *NonExisting) Get(client io.Writer, message http.RequestMessage)

func (*NonExisting) Head

func (nonExisting *NonExisting) Head(client io.Writer, message http.RequestMessage)

func (*NonExisting) Name

func (nonExisting *NonExisting) Name() string

type PartialSlice

type PartialSlice struct {
	Path           string
	ContentType    string
	FirstByteIndex int64
	LastByteIndex  int64
}

A slice of part of a file

func (*PartialSlice) WriteBody

func (slice *PartialSlice) WriteBody(writer io.Writer)

func (*PartialSlice) WriteContentHeaders

func (slice *PartialSlice) WriteContentHeaders(writer io.Writer)

func (*PartialSlice) WriteStatus

func (slice *PartialSlice) WriteStatus(writer io.Writer)

type ReadableFile

type ReadableFile struct {
	Filename string
}

An existing file that can be read or patched to an updated version

func (*ReadableFile) Get

func (readableFile *ReadableFile) Get(client io.Writer, message http.RequestMessage)

func (*ReadableFile) Head

func (readableFile *ReadableFile) Head(client io.Writer, message http.RequestMessage)

func (*ReadableFile) Name

func (readableFile *ReadableFile) Name() string

type ResourceFactory

type ResourceFactory interface {
	DirectoryListingResource(message http.RequestMessage, files []string) http.Resource
	ExistingFileResource(message http.RequestMessage, path string) http.Resource
	NonExistingResource(message http.RequestMessage) http.Resource
}

type SliceFactory

type SliceFactory struct {
	Filename    string
	ContentType string
	Size        int64
}

func (*SliceFactory) SliceCovering

func (factory *SliceFactory) SliceCovering(lowIndex, highIndex int64) FileSlice

type UnsupportedSlice

type UnsupportedSlice struct {
	Path     string
	NumBytes int64
}

An attempt to slice that is not supported

func (*UnsupportedSlice) WriteBody

func (slice *UnsupportedSlice) WriteBody(writer io.Writer)

func (*UnsupportedSlice) WriteContentHeaders

func (slice *UnsupportedSlice) WriteContentHeaders(writer io.Writer)

func (*UnsupportedSlice) WriteStatus

func (slice *UnsupportedSlice) WriteStatus(writer io.Writer)

type WholeFile

type WholeFile struct {
	Path        string
	ContentType string
}

A slice consisting of the entire file

func (*WholeFile) WriteBody

func (slice *WholeFile) WriteBody(writer io.Writer)

func (*WholeFile) WriteContentHeaders

func (slice *WholeFile) WriteContentHeaders(writer io.Writer)

func (*WholeFile) WriteStatus

func (slice *WholeFile) WriteStatus(writer io.Writer)

type WritableFile

type WritableFile struct {
	Filename string
}

An existing file with read/write access

func (*WritableFile) Get

func (writableFile *WritableFile) Get(client io.Writer, message http.RequestMessage)

func (*WritableFile) Head

func (writableFile *WritableFile) Head(client io.Writer, message http.RequestMessage)

func (*WritableFile) Name

func (writableFile *WritableFile) Name() string

func (*WritableFile) Patch

func (writableFile *WritableFile) Patch(client io.Writer, message http.RequestMessage)

func (*WritableFile) Put

func (writableFile *WritableFile) Put(client io.Writer, message http.RequestMessage)

type WritableFileRoute

type WritableFileRoute struct {
	UrlPath      string
	FileResource *WritableFile
}

func NewWritableFileRoute

func NewWritableFileRoute(urlPath, contentRootPath string) *WritableFileRoute

func (*WritableFileRoute) Route

func (route *WritableFileRoute) Route(requested http.RequestMessage) http.Request

Jump to

Keyboard shortcuts

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