hello.go 628 B

123456789101112131415161718192021222324252627
  1. package admin
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "net/http"
  5. "ulink-admin/frame"
  6. )
  7. type HelloController struct {
  8. }
  9. func (ctr *HelloController) Json(c *frame.Context) frame.Json {
  10. return gin.H{
  11. "hello": "world",
  12. }
  13. }
  14. func (ctr *HelloController) File(c *frame.Context) frame.File {
  15. head := http.Header{}
  16. head.Set("Content-Type", "application/octet-stream")
  17. head.Set("Content-Disposition", "attachment; filename="+"Workbook.xls")
  18. head.Set("Content-Transfer-Encoding", "binary")
  19. return frame.File{
  20. Data: []byte("123, 123, 12312, 3123"),
  21. ContentType: "application/octet-stream",
  22. FileName: "1.csv",
  23. }
  24. }