mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
docs and simplify
This commit is contained in:
parent
4a6c53a12b
commit
2414f2edec
@ -8,9 +8,9 @@ import (
|
||||
"github.com/hacdias/caddy-hugo/config"
|
||||
)
|
||||
|
||||
// ServeHTTP is used to serve the content of Browse page
|
||||
// using Browse middleware from Caddy. It handles the requests
|
||||
// for DELETE, POST, GET and PUT related to /browse interface.
|
||||
// ServeHTTP is used to serve the content of Browse page using Browse middleware
|
||||
// from Caddy. It handles the requests for DELETE, POST, GET and PUT related to
|
||||
// /browse interface.
|
||||
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
||||
// Removes the page main path from the URL
|
||||
r.URL.Path = strings.Replace(r.URL.Path, "/admin/browse", "", 1)
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/hacdias/caddy-hugo/config"
|
||||
)
|
||||
|
||||
// DELETE handles the DELETE method on browse page
|
||||
// DELETE handles the delete requests on browse pages
|
||||
func DELETE(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
||||
// Remove both beginning and trailing slashes
|
||||
path := r.URL.Path
|
||||
|
@ -10,7 +10,8 @@ import (
|
||||
"github.com/mholt/caddy/middleware/browse"
|
||||
)
|
||||
|
||||
// GET handles the GET method on browse page
|
||||
// GET handles the GET method on browse page and shows the files listing Using
|
||||
// the Browse Caddy middleware.
|
||||
func GET(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
||||
functions := template.FuncMap{
|
||||
"CanBeEdited": utils.CanBeEdited,
|
||||
|
@ -14,7 +14,8 @@ import (
|
||||
"github.com/hacdias/caddy-hugo/utils"
|
||||
)
|
||||
|
||||
// POST handles the POST method on browse page
|
||||
// POST handles the POST method on browse page. It's used to create new files,
|
||||
// folders and upload content.
|
||||
func POST(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
||||
// Remove prefix slash
|
||||
r.URL.Path = strings.TrimPrefix(r.URL.Path, "/")
|
||||
|
@ -40,9 +40,8 @@ func PUT(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error)
|
||||
new = strings.TrimSuffix(new, "/")
|
||||
new = c.Path + new
|
||||
|
||||
err := os.Rename(old, new)
|
||||
|
||||
if err != nil {
|
||||
// Renames the file/folder
|
||||
if err := os.Rename(old, new); err != nil {
|
||||
return 500, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user