@@ -26,6 +26,7 @@ import (
26
26
"github.com/1Panel-dev/1Panel/backend/utils/docker"
27
27
"github.com/1Panel-dev/1Panel/backend/utils/files"
28
28
http2 "github.com/1Panel-dev/1Panel/backend/utils/http"
29
+ httpUtil "github.com/1Panel-dev/1Panel/backend/utils/http"
29
30
"gopkg.in/yaml.v3"
30
31
)
31
32
@@ -226,21 +227,16 @@ func (a AppService) GetAppDetail(appID uint, version, appType string) (response.
226
227
if appDetailDTO .DockerCompose == "" {
227
228
filename := filepath .Base (appDetailDTO .DownloadUrl )
228
229
dockerComposeUrl := fmt .Sprintf ("%s%s" , strings .TrimSuffix (appDetailDTO .DownloadUrl , filename ), "docker-compose.yml" )
229
- composeRes , err := http . Get (dockerComposeUrl )
230
+ statusCode , composeRes , err := httpUtil . HandleGet (dockerComposeUrl , http . MethodGet )
230
231
if err != nil {
231
232
return appDetailDTO , buserr .WithDetail ("ErrGetCompose" , err .Error (), err )
232
233
}
233
- defer composeRes .Body .Close ()
234
- bodyContent , err := io .ReadAll (composeRes .Body )
235
- if err != nil {
236
- return appDetailDTO , buserr .WithDetail ("ErrGetCompose" , err .Error (), err )
237
- }
238
- if composeRes .StatusCode > 200 {
239
- return appDetailDTO , buserr .WithDetail ("ErrGetCompose" , string (bodyContent ), err )
234
+ if statusCode > 200 {
235
+ return appDetailDTO , buserr .WithDetail ("ErrGetCompose" , string (composeRes ), err )
240
236
}
241
- detail .DockerCompose = string (bodyContent )
237
+ detail .DockerCompose = string (composeRes )
242
238
_ = appDetailRepo .Update (context .Background (), detail )
243
- appDetailDTO .DockerCompose = string (bodyContent )
239
+ appDetailDTO .DockerCompose = string (composeRes )
244
240
}
245
241
246
242
appDetailDTO .HostMode = isHostModel (appDetailDTO .DockerCompose )
@@ -840,19 +836,14 @@ func (a AppService) SyncAppListFromRemote() (err error) {
840
836
global .LOG .Infof ("Starting synchronization of application details..." )
841
837
for _ , l := range list .Apps {
842
838
app := appsMap [l .AppProperty .Key ]
843
- iconRes , err := http .Get (l .Icon )
844
- if err != nil {
845
- return err
846
- }
847
- body , err := io .ReadAll (iconRes .Body )
839
+ _ , iconRes , err := httpUtil .HandleGet (l .Icon , http .MethodGet )
848
840
if err != nil {
849
841
return err
850
842
}
851
843
iconStr := ""
852
- if ! strings .Contains (string (body ), "<xml>" ) {
853
- iconStr = base64 .StdEncoding .EncodeToString (body )
844
+ if ! strings .Contains (string (iconRes ), "<xml>" ) {
845
+ iconStr = base64 .StdEncoding .EncodeToString (iconRes )
854
846
}
855
- _ = iconRes .Body .Close ()
856
847
857
848
app .Icon = iconStr
858
849
app .TagsKey = l .AppProperty .Tags
@@ -872,16 +863,11 @@ func (a AppService) SyncAppListFromRemote() (err error) {
872
863
873
864
if _ , ok := InitTypes [app .Type ]; ok {
874
865
dockerComposeUrl := fmt .Sprintf ("%s/%s" , versionUrl , "docker-compose.yml" )
875
- composeRes , err := http .Get (dockerComposeUrl )
876
- if err != nil {
877
- return err
878
- }
879
- defer composeRes .Body .Close ()
880
- bodyContent , err := io .ReadAll (composeRes .Body )
866
+ _ , composeRes , err := httpUtil .HandleGet (dockerComposeUrl , http .MethodGet )
881
867
if err != nil {
882
868
return err
883
869
}
884
- detail .DockerCompose = string (bodyContent )
870
+ detail .DockerCompose = string (composeRes )
885
871
} else {
886
872
detail .DockerCompose = ""
887
873
}
0 commit comments