staticfiles

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2020 License: Apache-2.0 Imports: 9 Imported by: 5 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package staticfiles provides middleware for serving static files from disk. Its handler is the default HTTP handler for the HTTP server.

TODO: Should this package be rolled into the httpserver package?

Index

Constants

This section is empty.

Variables

View Source
var DefaultIndexPages = []string{
	"index.html",
	"index.htm",
	"index.txt",
	"default.html",
	"default.htm",
	"default.txt",
}

DefaultIndexPages is a list of pages that may be understood as the "index" files to directories.

Functions

This section is empty.

Types

type FileServer

type FileServer struct {
	Root http.FileSystem // jailed access to the file system
	Hide []string        // list of files for which to respond with "Not Found"

	// A list of pages that may be understood as the "index" files to directories.
	// Injected from *SiteConfig.
	IndexPages []string
}

FileServer implements a production-ready file server and is the 'default' handler for all requests to Caddy. It simply loads and serves the URI requested. FileServer is adapted from the one in net/http by the Go authors. Significant modifications have been made.

Original license:

Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

func (FileServer) IsHidden added in v0.9.4

func (fs FileServer) IsHidden(d os.FileInfo) bool

IsHidden checks if file with FileInfo d is on hide list.

func (FileServer) ServeHTTP

func (fs FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)

ServeHTTP serves static files for r according to fs's configuration.

Jump to

Keyboard shortcuts

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