func readFile(filename string) string { file, err := os.Open(volumn + filename) defer file.Close() if err != nil { return err.Error() } else { b, err := ioutil.ReadAll(file) if err != nil { return err.Error() } return goutils.ToString(b) } }
// @router /upload/* [post,put] func (c *MainController) Upload() { rw := c.Ctx.ResponseWriter req := c.Ctx.Request // if req.Method == "GET" { // return // } b, err := ioutil.ReadAll(req.Body) if checkerr(err) { rw.Write([]byte(err.Error())) } filename := c.Ctx.Input.Param(":splat") createFile(filename, goutils.ToString(b)) }