git.iko.soy/typeable/oauth2-proxy
on master help sign in
Allow file server to handle windows filesystems
commitfa8e1ee0337fd5d712e8b6d94b3628ab00c1ef50 authorJoel Speed <joel.speed@hotmail.co.uk> dateWed 27 May 2020, 23:58 (6 years ago) parente1c3e93
1 file changed+11−1
pkg/upstream/file.go+11−1
pkg/upstream/file.go+11−1
@@ -1,6 +1,10 @@
11package upstream
22
3−import "net/http"
3+import (
4+ "net/http"
5+ "runtime"
6+ "strings"
7+)
48
59const fileScheme = "file"
610
@@ -15,6 +19,12 @@ func newFileServer(id, path, fileSystemPath string) http.Handler {
1519
1620// newFileServerForPath creates a http.Handler to serve files from the filesystem
1721func newFileServerForPath(path string, filesystemPath string) http.Handler {
22+ // Windows fileSSystemPath will be be prefixed with `/`, eg`/C:/...,
23+ // if they were parsed by url.Parse`
24+ if runtime.GOOS == "windows" {
25+ filesystemPath = strings.TrimPrefix(filesystemPath, "/")
26+ }
27+
1828 return http.StripPrefix(path, http.FileServer(http.Dir(filesystemPath)))
1929}
2030