caddy: github.com/mholt/caddy/caddyhttp/staticfiles Index | Files

package staticfiles

import "github.com/mholt/caddy/caddyhttp/staticfiles"

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

Package Files

fileserver.go

Variables

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.

type FileServer Uses

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 Uses

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

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

func (FileServer) ServeHTTP Uses

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

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

Package staticfiles imports 9 packages (graph) and is imported by 253 packages. Updated 2019-10-08. Refresh now. Tools for package owners.