api

package
v0.0.0-...-55d983f Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GraphQLHandler

func GraphQLHandler() http.Handler

GraphQLHandler returns http.Handler for the graphql endpoint

func QuerySort

func QuerySort(sortq string, files []os.FileInfo) (err error)

QuerySort sort the files by the provided query string

func ServeAPI

func ServeAPI(path string, root http.FileSystem) midway.Middleware

ServeAPI generates a middleware to serve API for file / directory information query

func SortBy

func SortBy(by string, files []os.FileInfo) (s sort.Interface, err error)

SortBy sorts the files

Types

type ByModTime

type ByModTime []os.FileInfo

ByModTime sorts []os.FileInfo by the ModTime() results

func (ByModTime) Len

func (fi ByModTime) Len() int

Len is the number of elements in the collection.

func (ByModTime) Less

func (fi ByModTime) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (ByModTime) Swap

func (fi ByModTime) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type ByName

type ByName []os.FileInfo

ByName sorts []os.FileInfo by Name() results

func (ByName) Len

func (fi ByName) Len() int

Len is the number of elements in the collection.

func (ByName) Less

func (fi ByName) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (ByName) Swap

func (fi ByName) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type ByType

type ByType []os.FileInfo

ByType sorts directory before files in []os.FileInfo

func (ByType) Len

func (fi ByType) Len() int

Len is the number of elements in the collection.

func (ByType) Less

func (fi ByType) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (ByType) Swap

func (fi ByType) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type DirStat

type DirStat struct {
	Name  string
	Path  string
	MTime time.Time
}

DirStat stores and display a directory's information as JSON

func (DirStat) MarshalJSON

func (file DirStat) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler

type FileInfo

type FileInfo struct {
	Name     string    `json:"name"`
	Path     string    `json:"path,omitempty"`
	Type     string    `json:"type"`
	Mime     string    `json:"mime,omitempty"`
	HasIndex bool      `json:"hasIndex,omitempty"`
	Size     int64     `json:"size,omitempty"`
	MTime    time.Time `json:"mtime,omitempty"`
	Links    []Link    `json:"links,omitempty"`
}

FileInfo is a JSON display of a subset of os.FileInfo information

type FileStat

type FileStat struct {
	Name  string
	Path  string
	Size  int64
	MTime time.Time
}

FileStat stores and display a file's information as JSON

func (FileStat) MarshalJSON

func (file FileStat) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler

type Link struct {
	Rel  string `json:"rel"`
	Href string `json:"href"`
}

Link contains a HATEOAS hypermedia reference URL

type StatError

type StatError struct {
	Code int
	Path string
}

StatError represents an error in JSON format

func NewStatError

func NewStatError(code int, path string) *StatError

NewStatError returns a new StatError

func (StatError) Error

func (err StatError) Error() string

Error implements error interface

func (StatError) MarshalJSON

func (err StatError) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler

func (StatError) Message

func (err StatError) Message() string

Message return message for a given error

Jump to

Keyboard shortcuts

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