file

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

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

Go to latest
Published: Apr 20, 2017 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

HTTP file system request handler

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UploadServer

func UploadServer(mx *chi.Mux, path string, fileRoot string)

Types

type Dir

type Dir string

A Dir implements FileSystem using the native file system restricted to a specific directory tree.

While the FileSystem.Open method takes '/'-separated paths, a Dir's string value is a filename on the native file system, not a URL, so it is separated by filepath.Separator, which isn't necessarily '/'.

An empty Dir is treated as ".".

func (Dir) Create

func (d Dir) Create(name string) (http.File, error)

func (Dir) Delete

func (d Dir) Delete(name string) error

func (Dir) Mkdir

func (d Dir) Mkdir(name string) (http.File, error)

func (Dir) Open

func (d Dir) Open(name string) (http.File, error)

func (Dir) Rename

func (d Dir) Rename(name string, new string) error

func (Dir) Update

func (d Dir) Update(name string, content string) error

type File

type File struct {
	Url     string `json:"url"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Content string `json:"content"`
}

type FileHandler

type FileHandler struct {
	// contains filtered or unexported fields
}

func FileServer

func FileServer(root FileSystem) *FileHandler

FileServer returns a handler that serves HTTP requests with the contents of the file system rooted at root.

To use the operating system's file system implementation, use http.Dir:

http.Handle("/", http.FileServer(http.Dir("/tmp")))

As a special case, the returned file server redirects any request ending in "/index.html" to the same path, without the final "index.html".

func (*FileHandler) Delete

func (f *FileHandler) Delete(w http.ResponseWriter, r *http.Request)

func (*FileHandler) Get

func (f *FileHandler) Get(w http.ResponseWriter, r *http.Request)

func (*FileHandler) Post

func (f *FileHandler) Post(w http.ResponseWriter, r *http.Request)

func (*FileHandler) Put

func (f *FileHandler) Put(w http.ResponseWriter, r *http.Request)

type FileSystem

type FileSystem interface {
	Mkdir(name string) (http.File, error)
	Open(name string) (http.File, error)
	Create(name string) (http.File, error)
	Delete(name string) error
	Rename(old string, new string) error
	Update(name string, content string) error
}

type PutRequest

type PutRequest struct {
	Cmd  string           `json:"cmd"`
	Data *json.RawMessage `json:"data"`
}

type Upload

type Upload string

func (Upload) Post

func (p Upload) Post(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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