Documentation ¶
Overview ¶
HTTP file system request handler
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ".".
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 PutRequest ¶
type PutRequest struct { Cmd string `json:"cmd"` Data *json.RawMessage `json:"data"` }