filebrowser/routes/editor/editor.go

24 lines
497 B
Go
Raw Normal View History

2015-09-18 15:49:53 +00:00
package editor
import (
"net/http"
"strings"
2015-10-18 14:10:32 +00:00
"github.com/hacdias/caddy-hugo/config"
2015-09-18 15:49:53 +00:00
)
2015-09-20 08:15:21 +00:00
// ServeHTTP serves the editor page
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
2016-06-16 16:01:41 +00:00
filename := strings.Replace(r.URL.Path, c.Admin+"/edit/", "", 1)
2015-09-30 21:03:28 +00:00
filename = c.Path + filename
2015-09-18 15:49:53 +00:00
2015-09-26 21:02:49 +00:00
switch r.Method {
2016-06-16 16:01:41 +00:00
case http.MethodPost:
return POST(w, r, c, filename)
case http.MethodGet:
return GET(w, r, c, filename)
2015-09-19 13:25:35 +00:00
default:
2016-06-16 16:01:41 +00:00
return http.StatusNotImplemented, nil
2015-09-19 13:25:35 +00:00
}
2015-09-19 13:47:59 +00:00
}