Standalone

Former-commit-id: b038d91a5a5a8f0e4d3764b15bc9a0d794794a7b [formerly 0b8133d71d207fcdcbcc5c11bd1a8206c26261e3] [formerly 51bef56f774c2f75bfc65a378103196af9a7775c [formerly d1c6daf647]]
Former-commit-id: 6c05933dfa591fbe6f98910143a3f035e2e5d763 [formerly 5d46ca10688eb150dff935472cc17b47b790446e]
Former-commit-id: e9e682359e0eb9b081762bca699b498454cff435
This commit is contained in:
Henrique Dias
2017-07-20 09:03:14 +01:00
parent c443ce7a71
commit 05270bc946
6 changed files with 145 additions and 10 deletions

View File

@@ -322,20 +322,32 @@ func (m *FileManager) RegisterPermission(name string, value bool) error {
}
// ServeHTTP determines if the request is for this plugin, and if all prerequisites are met.
func (m *FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
// Compatible with http.Handler.
func (m *FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) {
code, err := serveHTTP(&RequestContext{
FM: m,
User: nil,
FI: nil,
}, w, r)
if code != 0 && err != nil {
if code != 0 {
w.WriteHeader(code)
w.Write([]byte(err.Error()))
return 0, nil
}
return code, err
if err != nil {
w.Write([]byte(err.Error()))
} else {
w.Write([]byte(http.StatusText(code)))
}
}
}
// ServeWithErrorHTTP returns the code and error of the request.
func (m *FileManager) ServeWithErrorHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
return serveHTTP(&RequestContext{
FM: m,
User: nil,
FI: nil,
}, w, r)
}
// Allowed checks if the user has permission to access a directory/file.