Documentation ¶
Index ¶
Constants ¶
const URLPathCtxKey caddy.CtxKey = "url_path"
URLPathCtxKey is a context key. It can be used in HTTP handlers with context.WithValue to access the original request URI that accompanied the server request. The associated value will be of type string.
Variables ¶
var IndexPages = []string{
"index.html",
"index.htm",
"index.txt",
"default.html",
"default.htm",
"default.txt",
}
IndexPages is a list of pages that may be understood as the "index" files to directories.
Functions ¶
func RedirectToDir ¶ added in v0.10.0
func RedirectToDir(w http.ResponseWriter, r *http.Request)
RedirectToDir replies to the request with a redirect to the URL in r, which has been transformed to indicate that the resource being requested is a directory.
func RedirectToFile ¶ added in v0.10.0
func RedirectToFile(w http.ResponseWriter, r *http.Request)
RedirectToFile replies to the request with a redirect to the URL in r, which has been transformed to indicate that the resource being requested is a file.
Types ¶
type FileServer ¶
type FileServer struct { // Jailed disk access Root http.FileSystem // List of files to treat as "Not Found" Hide []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.