Serving data from reader
Konten ini belum tersedia dalam bahasa Anda.
func main() {  router := gin.Default()  router.GET("/someDataFromReader", func(c *gin.Context) {    response, err := http.Get("https://raw.githubusercontent.com/gin-gonic/logo/master/color.png")    if err != nil || response.StatusCode != http.StatusOK {      c.Status(http.StatusServiceUnavailable)      return    }
    reader := response.Body    contentLength := response.ContentLength    contentType := response.Header.Get("Content-Type")
    extraHeaders := map[string]string{      "Content-Disposition": `attachment; filename="gopher.png"`,    }
    c.DataFromReader(http.StatusOK, contentLength, contentType, reader, extraHeaders)  })  router.Run(":8080")}