mirror of
https://github.com/golang/go
synced 2024-11-26 03:37:57 -07:00
net/http: document io.Seeker requirement for fs.FS arguments
Using the same wording as http.FS, even though it's not strictly required if a content type can be determined by file extension. Fixes #66877 Updates #44553 Change-Id: I7b70c10909bdd289a57d1998a565262b8aaf2dd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/597977 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
071b8d51c1
commit
5d36bc18d5
@ -35,7 +35,7 @@ func NewFileTransport(fs FileSystem) RoundTripper {
|
|||||||
// NewFileTransportFS returns a new [RoundTripper], serving the provided
|
// NewFileTransportFS returns a new [RoundTripper], serving the provided
|
||||||
// file system fsys. The returned RoundTripper ignores the URL host in its
|
// file system fsys. The returned RoundTripper ignores the URL host in its
|
||||||
// incoming requests, as well as most other properties of the
|
// incoming requests, as well as most other properties of the
|
||||||
// request.
|
// request. The files provided by fsys must implement [io.Seeker].
|
||||||
//
|
//
|
||||||
// The typical use case for NewFileTransportFS is to register the "file"
|
// The typical use case for NewFileTransportFS is to register the "file"
|
||||||
// protocol with a [Transport], as in:
|
// protocol with a [Transport], as in:
|
||||||
|
@ -819,6 +819,7 @@ func ServeFile(w ResponseWriter, r *Request, name string) {
|
|||||||
|
|
||||||
// ServeFileFS replies to the request with the contents
|
// ServeFileFS replies to the request with the contents
|
||||||
// of the named file or directory from the file system fsys.
|
// of the named file or directory from the file system fsys.
|
||||||
|
// The files provided by fsys must implement [io.Seeker].
|
||||||
//
|
//
|
||||||
// If the provided name is constructed from user input, it should be
|
// If the provided name is constructed from user input, it should be
|
||||||
// sanitized before calling [ServeFileFS].
|
// sanitized before calling [ServeFileFS].
|
||||||
@ -965,6 +966,7 @@ func FileServer(root FileSystem) Handler {
|
|||||||
|
|
||||||
// FileServerFS returns a handler that serves HTTP requests
|
// FileServerFS returns a handler that serves HTTP requests
|
||||||
// with the contents of the file system fsys.
|
// with the contents of the file system fsys.
|
||||||
|
// The files provided by fsys must implement [io.Seeker].
|
||||||
//
|
//
|
||||||
// As a special case, the returned file server redirects any request
|
// As a special case, the returned file server redirects any request
|
||||||
// ending in "/index.html" to the same path, without the final
|
// ending in "/index.html" to the same path, without the final
|
||||||
|
Loading…
Reference in New Issue
Block a user