I want to close an mgo session after it' fully streamed to the client. At first, I thought this might work, but it seems the defer
just waits until the the func begins to return or something.
func (c App) OpenFile(fileId string) revel.Result {
// convert string to bson.ObjectId
objId := bson.ObjectIdHex(fileId)
file, session := OpenFile(objId)
defer session.Close()
// memfile io.Reader, filename string, delivery ContentDisposition, modtime time.Time
var now = time.Now()
return c.RenderBinary(file, "filename", "inline", now)
}