fileserver

package
v0.0.0-...-c1a3bfb Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT, BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package fileserver provides a filesystem HTTP handler, based on the built-in Go FileServer. Extensions include better directory listings, support for injection, better and use of Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileServer

type FileServer struct {
	Version        string
	Root           http.FileSystem
	Inject         inject.CopyInject
	Templates      *template.Template
	NotFoundRoutes []routespec.RouteSpec
	Prefix         string
}

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("/", &fileserver.FileServer{Root: http.Dir("/tmp")})

func (*FileServer) ServeHTTP

func (fserver *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*FileServer) ServeHTTPContext

func (fserver *FileServer) ServeHTTPContext(
	ctx context.Context, w http.ResponseWriter, r *http.Request,
)

ServeHTTPContext is like ServeHTTP, but with added context

Jump to

Keyboard shortcuts

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