func (c *ContentController) commitChanges(f *model.VersionedFile, e *httpapp.Env) { session := e.Get("session").(*sessions.Session) user := session.Data["user"].(*auth.GoogleUser) out := f.CommitFor(user.AuthorString()) log.Print(out) }
func (c *ContentController) handleFilePUT(f *model.VersionedFile, e *httpapp.Env) *httpapp.Response { f.Write(util.SlurpRequestBody(e)) c.commitChanges(f, e) return httpapp.NewResponse(http.StatusNoContent) }
func (c *ContentController) handleFileDELETE(f *model.VersionedFile, e *httpapp.Env) *httpapp.Response { f.Remove() c.commitChanges(f, e) return httpapp.NewResponse(http.StatusNoContent) }
func (c *ContentController) handleFileGET(f *model.VersionedFile, e *httpapp.Env) *httpapp.Response { resp := httpapp.NewResponse(http.StatusOK) resp.Headers.Add("Content-Type", util.GuessMediaType(f.Name())) resp.Body.WriteString(f.Read()) return resp }