From 885f11d324847158a43a526987730f97fb81f508 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 20 Jul 2017 09:44:27 +0100 Subject: [PATCH] Remove unused function and update docs Former-commit-id: d7647f50647ee98107067ed6a17efc5e5ddd491a [formerly 0743e585ce077ea04dad4a21a2c6988fd2c0c2be] [formerly 3a7305c7a9c7d3e61895e49a0fb9db54a83ac9f5 [formerly 58ae0e7f31ebc13ba2ba72254bc61859c99240d4]] Former-commit-id: e3ca983a2e072a4c9c1b93d5b087b4e9636fd7cf [formerly 83ff193587ab7ae0381c1d27fa5939fe118dc1a6] Former-commit-id: 4f59b1c555df293ddd3bed3dee5b4c4aab7e532f --- doc.go | 39 ++++++++++++++++++++++++++++++++++----- filemanager.go | 7 ------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/doc.go b/doc.go index bfa73b22..18cb52a2 100644 --- a/doc.go +++ b/doc.go @@ -1,10 +1,39 @@ /* -Package filemanager provides a web interface to access -your files wherever you are. +Package filemanager provides a web interface to access your files +wherever you are. To use this package as a middleware for your app, +you'll need to create a filemanager instance: -To use this package, you'll need to start by creating a -filemanager instance: + m, err := filemanager.New(database, user) - fm, err := New(database, user) +Where 'user' contains the default options for new users. You can just +use 'filemanager.DefaultUser' + +Then, you should set the Prefix URL and the Base URL, using the following +functions: + + m.SetBaseURL("/") + m.SetPrefixURL("/") + +The Prefix URL is a part of the path that is already stripped from the +r.URL.Path variable before the request arrives to File Manager's handler. +This is a function that will rarely be used. You can see one example on Caddy +filemanager plugin. + +The Base URL is the URL path where you want File Manager to be available in. If +you want to be available at the root path, you should call: + + m.SetBaseURL("/") + +But if you want to access it at '/admin', you would call: + + m.SetBaseURL("/admin") + +Now, that you already have a File Manager instance created, you just need to +add it to your handlers using m.ServeHTTP which is compatible to http.Handler. +We also have a m.ServeWithErrorsHTTP that returns the status code and an error. + +One simple implementation for this, at port 80, in the root of the domain, would be: + + http.ListenAndServe(":80", m) */ package filemanager diff --git a/filemanager.go b/filemanager.go index 56bdc898..1a72dff9 100644 --- a/filemanager.go +++ b/filemanager.go @@ -372,13 +372,6 @@ func (u User) Allowed(url string) bool { return true } -// SetScope updates a user scope and its virtual file system. -// If the user string is blank, it will change the base scope. -func (u *User) SetScope(scope string) { - scope = strings.TrimSuffix(scope, "/") - u.FileSystem = webdav.Dir(scope) -} - // MatchString checks if this string matches the regular expression. func (r *Regexp) MatchString(s string) bool { if r.regexp == nil {