2015-09-18 16:49:53 +01:00
|
|
|
package editor
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"strings"
|
|
|
|
|
|
2015-09-27 20:01:44 +01:00
|
|
|
"github.com/hacdias/caddy-cms/config"
|
2015-09-18 16:49:53 +01:00
|
|
|
)
|
|
|
|
|
|
2015-09-20 09:15:21 +01:00
|
|
|
// ServeHTTP serves the editor page
|
|
|
|
|
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
2015-09-18 16:49:53 +01:00
|
|
|
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
|
|
|
|
|
|
2015-09-26 22:02:49 +01:00
|
|
|
switch r.Method {
|
|
|
|
|
case "POST":
|
|
|
|
|
return POST(w, r, c, filename)
|
|
|
|
|
case "GET":
|
|
|
|
|
return GET(w, r, c, filename)
|
2015-09-19 14:25:35 +01:00
|
|
|
default:
|
|
|
|
|
return 400, nil
|
|
|
|
|
}
|
2015-09-19 14:47:59 +01:00
|
|
|
}
|