rimgo/pages/media.go

20 lines
424 B
Go
Raw Normal View History

2022-01-17 20:23:04 +00:00
package pages
import (
"net/http"
2022-01-17 20:48:24 +00:00
"strconv"
2022-01-17 20:23:04 +00:00
"github.com/gofiber/fiber/v2"
)
func HandleMedia(c *fiber.Ctx) error {
2022-01-17 20:48:24 +00:00
res, err := http.Get("https://i.imgur.com/" + c.Params("baseName") + "." + c.Params("extension"))
2022-01-17 20:23:04 +00:00
if err != nil {
return err
}
c.Set("Content-Type", res.Header.Get("Content-Type"));
2022-01-17 20:48:24 +00:00
contentLen, _ := strconv.Atoi(res.Header.Get("Content-Length"))
c.SendStream(res.Body, contentLen)
2022-01-17 20:23:04 +00:00
return nil
}