You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
Error box, download button, editor save and more.
Former-commit-id: c14972384cc8afad28d49388b0b4545669e20b7d [formerly 0af2e5f9aff2aac576044ca9590045f656fbffda] [formerly 02248a86b7063e1c9d6779c3574a848708ff86f2 [formerly efaa8439a9]]
Former-commit-id: 4ce0a81ea04b56cef11d62107d692502e266a16e [formerly 2c46db9398c267351c10f06c089ed08dc3625232]
Former-commit-id: 1c93a0643217ab69668600b41e2d8263266d7e23
This commit is contained in:
@@ -19,9 +19,15 @@ var (
|
||||
// FileManager is a file manager instance. It should be creating using the
|
||||
// 'New' function and not directly.
|
||||
type FileManager struct {
|
||||
db *storm.DB
|
||||
// The BoltDB database for this instance.
|
||||
db *storm.DB
|
||||
|
||||
// The key used to sign the JWT tokens.
|
||||
key []byte
|
||||
|
||||
// The static assets.
|
||||
assets *rice.Box
|
||||
|
||||
// PrefixURL is a part of the URL that is already trimmed from the request URL before it
|
||||
// arrives to our handlers. It may be useful when using File Manager as a middleware
|
||||
// such as in caddy-filemanager plugin. It is only useful in certain situations.
|
||||
@@ -35,7 +41,8 @@ type FileManager struct {
|
||||
// Users is a map with the different configurations for each user.
|
||||
Users map[string]*User
|
||||
|
||||
assets *rice.Box
|
||||
// The plugins that have been plugged in.
|
||||
Plugins []*Plugin
|
||||
}
|
||||
|
||||
// Command is a command function.
|
||||
@@ -96,6 +103,12 @@ type Regexp struct {
|
||||
regexp *regexp.Regexp
|
||||
}
|
||||
|
||||
// Plugin is a File Manager plugin.
|
||||
type Plugin struct {
|
||||
// The JavaScript that will be injected into the main page.
|
||||
JavaScript string
|
||||
}
|
||||
|
||||
// DefaultUser is used on New, when no 'base' user is provided.
|
||||
var DefaultUser = User{
|
||||
Username: "admin",
|
||||
@@ -208,11 +221,19 @@ func (m *FileManager) SetBaseURL(url string) {
|
||||
// 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) {
|
||||
// TODO: Handle errors here and make it compatible with http.Handler
|
||||
return serveHTTP(&requestContext{
|
||||
code, err := serveHTTP(&requestContext{
|
||||
fm: m,
|
||||
us: nil,
|
||||
fi: nil,
|
||||
}, w, r)
|
||||
|
||||
if code != 0 && err != nil {
|
||||
w.WriteHeader(code)
|
||||
w.Write([]byte(err.Error()))
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
return code, err
|
||||
}
|
||||
|
||||
// Allowed checks if the user has permission to access a directory/file.
|
||||
|
||||
Reference in New Issue
Block a user