Files
request/v2/image.go
Matheus Sampaio Queiroga e19f99af2d
All checks were successful
Golang test / go-test (push) Successful in 16s
Update gitea structs and add more functions
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2025-06-27 22:08:26 -03:00

63 lines
1.8 KiB
Go

package request
import (
"image"
"net/http"
"net/url"
)
// Make request and return [image.Image]
//
// Require import modules to [image.Decode], see [image] to more info
func Image(Url string, RequestOption *Options) (image.Image, string, *http.Response, error) {
res, err := Request(Url, RequestOption)
if err != nil {
return nil, "", nil, err
}
defer res.Body.Close()
imageDecode, imageType, err := image.Decode(res.Body)
return imageDecode, imageType, res, err
}
// Make request and return [image.Image]
//
// Require import modules to [image.Decode], see [image] to more info
func MakeImage(Url *url.URL, RequestOption *Options) (image.Image, string, *http.Response, error) {
res, err := MakeRequestWithStatus(Url, RequestOption)
if err != nil {
return nil, "", nil, err
}
defer res.Body.Close()
imageDecode, imageType, err := image.Decode(res.Body)
return imageDecode, imageType, res, err
}
// Make request and return [image.DecodeConfig]
//
// Require import modules to [image.DecodeConfig], see [image] to more info
func ImageConfig(Url string, RequestOption *Options) (image.Config, string, *http.Response, error) {
res, err := Request(Url, RequestOption)
if err != nil {
return image.Config{}, "", nil, err
}
defer res.Body.Close()
imageDecode, imageType, err := image.DecodeConfig(res.Body)
return imageDecode, imageType, res, err
}
// Make request and return [image.DecodeConfig]
//
// Require import modules to [image.DecodeConfig], see [image] to more info
func MakeImageConfig(Url *url.URL, RequestOption *Options) (image.Config, string, *http.Response, error) {
res, err := MakeRequestWithStatus(Url, RequestOption)
if err != nil {
return image.Config{}, "", nil, err
}
defer res.Body.Close()
imageDecode, imageType, err := image.DecodeConfig(res.Body)
return imageDecode, imageType, res, err
}