From 2414f2edecdeca7bcd11330d4585d6440933b971 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 14 Feb 2016 10:20:47 +0000 Subject: [PATCH] docs and simplify --- browse/browse.go | 6 +++--- browse/delete.go | 2 +- browse/get.go | 3 ++- browse/post.go | 3 ++- browse/put.go | 5 ++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/browse/browse.go b/browse/browse.go index c53adbdf..9b52167a 100644 --- a/browse/browse.go +++ b/browse/browse.go @@ -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) diff --git a/browse/delete.go b/browse/delete.go index 72099039..dc7ff36e 100644 --- a/browse/delete.go +++ b/browse/delete.go @@ -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 diff --git a/browse/get.go b/browse/get.go index 12afc8a6..453b2388 100644 --- a/browse/get.go +++ b/browse/get.go @@ -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, diff --git a/browse/post.go b/browse/post.go index e2503999..821be4c9 100644 --- a/browse/post.go +++ b/browse/post.go @@ -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, "/") diff --git a/browse/put.go b/browse/put.go index a8e3f604..ad7e9de5 100644 --- a/browse/put.go +++ b/browse/put.go @@ -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 }