2015-09-16 04:40:46 +08:00
|
|
|
package browse
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2015-09-18 00:41:31 +08:00
|
|
|
"strings"
|
2015-09-16 04:40:46 +08:00
|
|
|
|
2015-09-28 03:01:44 +08:00
|
|
|
"github.com/hacdias/caddy-cms/config"
|
2015-09-16 04:40:46 +08:00
|
|
|
)
|
|
|
|
|
2015-09-20 16:15:21 +08: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-18 00:41:31 +08:00
|
|
|
r.URL.Path = strings.Replace(r.URL.Path, "/admin/browse", "", 1)
|
|
|
|
|
2015-09-21 03:42:22 +08:00
|
|
|
switch r.Method {
|
|
|
|
case "DELETE":
|
2015-10-01 05:03:28 +08:00
|
|
|
return DELETE(w, r, c)
|
2015-09-21 03:42:22 +08:00
|
|
|
case "POST":
|
2015-10-01 05:03:28 +08:00
|
|
|
return POST(w, r, c)
|
2015-09-21 03:42:22 +08:00
|
|
|
case "GET":
|
2015-09-27 05:02:49 +08:00
|
|
|
return GET(w, r, c)
|
2015-09-21 03:42:22 +08:00
|
|
|
default:
|
|
|
|
return 400, nil
|
2015-09-18 00:41:31 +08:00
|
|
|
}
|
2015-09-21 03:42:22 +08:00
|
|
|
}
|