filebrowser/editor/editor.go

25 lines
491 B
Go
Raw Normal View History

2015-09-18 23:49:53 +08:00
package editor
import (
2015-10-17 03:03:59 +08:00
"errors"
2015-09-18 23:49:53 +08:00
"net/http"
"strings"
2015-10-18 22:10:32 +08:00
"github.com/hacdias/caddy-hugo/config"
2015-09-18 23:49:53 +08:00
)
2015-09-20 16:15:21 +08:00
// ServeHTTP serves the editor page
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
2015-09-18 23:49:53 +08:00
filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1)
2015-10-01 05:03:28 +08:00
filename = c.Path + filename
2015-09-18 23:49:53 +08:00
2015-09-27 05:02:49 +08:00
switch r.Method {
case "POST":
return POST(w, r, c, filename)
case "GET":
return GET(w, r, c, filename)
2015-09-19 21:25:35 +08:00
default:
2015-10-17 03:03:59 +08:00
return 400, errors.New("Invalid method.")
2015-09-19 21:25:35 +08:00
}
2015-09-19 21:47:59 +08:00
}