mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
31 lines
551 B
Go
31 lines
551 B
Go
package editor
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"strings"
|
|
|
|
"github.com/hacdias/caddy-hugo/config"
|
|
)
|
|
|
|
var (
|
|
filename string
|
|
conf *config.Config
|
|
)
|
|
|
|
// ServeHTTP serves the editor page
|
|
func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
|
conf = c
|
|
filename = strings.Replace(r.URL.Path, c.Admin+"/edit/", "", 1)
|
|
filename = c.Path + filename
|
|
|
|
switch r.Method {
|
|
case "POST":
|
|
return POST(w, r)
|
|
case "GET":
|
|
return GET(w, r)
|
|
default:
|
|
return http.StatusMethodNotAllowed, errors.New("Invalid method.")
|
|
}
|
|
}
|