summaryrefslogtreecommitdiff
path: root/system/admin/filesystem.go
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2016-11-16 02:51:26 -0800
committerGitHub <noreply@github.com>2016-11-16 02:51:26 -0800
commitf252472047f86d1bdf956dc59b89541ea0260d68 (patch)
tree6c0d5938c21505325ad50446f5ebcd1483d6b278 /system/admin/filesystem.go
parent9a531ac701990bb932664039b11614227467e03a (diff)
parent6f5893828077eb0034dca01344f3742eb5cd5fa6 (diff)
Merge pull request #17 from bosssauce/ponzu-dev
[core] Adding lifecycle hooks for Save, Delete, Approve, Reject
Diffstat (limited to 'system/admin/filesystem.go')
-rw-r--r--system/admin/filesystem.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/system/admin/filesystem.go b/system/admin/filesystem.go
new file mode 100644
index 0000000..4e64a26
--- /dev/null
+++ b/system/admin/filesystem.go
@@ -0,0 +1,36 @@
+package admin
+
+import (
+ "net/http"
+ "os"
+)
+
+
+func restrict(dir http.Dir) justFilesFilesystem {
+ return justFilesFilesystem{dir}
+}
+
+// the code below removes the open directory listing when accessing a URL which
+// normally would point to a directory. code from golang-nuts mailing list:
+// https://groups.google.com/d/msg/golang-nuts/bStLPdIVM6w/hidTJgDZpHcJ
+// credit: Brad Fitzpatrick (c) 2012
+
+type justFilesFilesystem struct {
+ fs http.FileSystem
+}
+
+func (fs justFilesFilesystem) Open(name string) (http.File, error) {
+ f, err := fs.fs.Open(name)
+ if err != nil {
+ return nil, err
+ }
+ return neuteredReaddirFile{f}, nil
+}
+
+type neuteredReaddirFile struct {
+ http.File
+}
+
+func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) {
+ return nil, nil
+}