filebrowser/edit/edit.go

30 lines
462 B
Go
Raw Normal View History

2015-09-12 19:02:26 +00:00
package edit
import (
"io/ioutil"
"net/http"
"os"
)
type Page struct {
}
// Execute sth
func Execute(w http.ResponseWriter, r *http.Request, file string) (int, error) {
if r.Method == "POST" {
// it's saving the post
} else {
// check if the file exists
if _, err := os.Stat(file); os.IsNotExist(err) {
return 404, nil
}
file, _ := ioutil.ReadFile(file)
2015-09-12 21:18:29 +00:00
// render the template here
2015-09-12 19:02:26 +00:00
w.Write([]byte(string(file)))
}
return 200, nil
}