Files
filebrowser/editor/editor.go
T

33 lines
600 B
Go
Raw Normal View History

2015-09-18 16:49:53 +01:00
package editor
import (
"net/http"
"strings"
2015-09-20 09:15:21 +01:00
"github.com/hacdias/caddy-hugo/config"
2015-09-18 16:49:53 +01:00
)
type editor struct {
Name string
Class string
2015-09-25 21:06:29 +01:00
IsPost bool
2015-09-19 14:47:59 +01:00
Mode string
2015-09-18 16:49:53 +01:00
Content string
FrontMatter interface{}
2015-09-20 09:15:21 +01:00
Config *config.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
}