filebrowser/browse/browse.go

27 lines
545 B
Go
Raw Normal View History

package browse
import (
"net/http"
2015-09-17 16:41:31 +00:00
"strings"
2015-09-20 08:15:21 +00:00
"github.com/hacdias/caddy-hugo/config"
)
2015-09-20 08:15:21 +00:00
// ServeHTTP is used to serve the content of Browse page
// using Browse middleware from Caddy
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
// Removes the page main path from the URL
2015-09-17 16:41:31 +00:00
r.URL.Path = strings.Replace(r.URL.Path, "/admin/browse", "", 1)
2015-09-20 19:42:22 +00:00
switch r.Method {
case "DELETE":
2015-09-26 21:02:49 +00:00
return DELETE(w, r)
2015-09-20 19:42:22 +00:00
case "POST":
2015-09-26 21:02:49 +00:00
return POST(w, r)
2015-09-20 19:42:22 +00:00
case "GET":
2015-09-26 21:02:49 +00:00
return GET(w, r, c)
2015-09-20 19:42:22 +00:00
default:
return 400, nil
2015-09-17 16:41:31 +00:00
}
2015-09-20 19:42:22 +00:00
}