Add support for file editor

This commit is contained in:
marcos
2018-01-05 13:13:07 -03:00
parent f564f1fd28
commit 386bd87385
32 changed files with 621 additions and 93 deletions

View File

@@ -0,0 +1,42 @@
package handlers
import (
"io"
"log"
"net/http"
"github.com/gorilla/mux"
)
func fsTree(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
sessionId := vars["sessionId"]
instanceName := vars["instanceName"]
s, _ := core.SessionGet(sessionId)
if s == nil {
rw.WriteHeader(http.StatusNotFound)
return
}
i := core.InstanceGet(s, instanceName)
if i == nil {
rw.WriteHeader(http.StatusNotFound)
return
}
tree, err := core.InstanceFSTree(i)
if err != nil {
log.Println(err)
rw.WriteHeader(http.StatusInternalServerError)
return
}
rw.Header().Set("content-type", "application/json")
if _, err = io.Copy(rw, tree); err != nil {
log.Println(err)
rw.WriteHeader(http.StatusInternalServerError)
return
}
}