@@ -23,11 +23,27 @@ func (s *Service) DownloadHandler(c *gin.Context) {
2323 }
2424 err := pkg .FillByName (name )
2525 if err != nil {
26- c .JSON (500 , gin.H {"error" : "Error while trying to get package info" })
26+ c .JSON (500 , gin.H {
27+ "errors" : []gin.H {
28+ {
29+ "code" : "DENIED" ,
30+ "message" : "authentication required" ,
31+ "detail" : "Error while trying to get package info" ,
32+ },
33+ },
34+ })
2735 return
2836 }
2937 if pkg .ID == uuid .Nil {
30- c .JSON (404 , gin.H {"error" : "Package not found" })
38+ c .JSON (404 , gin.H {
39+ "errors" : []gin.H {
40+ {
41+ "code" : "DENIED" ,
42+ "message" : "authentication required" ,
43+ "detail" : "Package not found" ,
44+ },
45+ },
46+ })
3147 return
3248 }
3349
@@ -36,17 +52,41 @@ func (s *Service) DownloadHandler(c *gin.Context) {
3652 }
3753 err = asset .FillByDigest (digest )
3854 if err != nil {
39- c .JSON (500 , gin.H {"error" : "Unable to check the DB for package version" })
55+ c .JSON (500 , gin.H {
56+ "errors" : []gin.H {
57+ {
58+ "code" : "DENIED" ,
59+ "message" : "authentication required" ,
60+ "detail" : "Unable to check the DB for package version" ,
61+ },
62+ },
63+ })
4064 return
4165 }
4266 if asset .Digest != digest {
43- c .JSON (404 , gin.H {"error" : "Uploaded asset not found" })
67+ c .JSON (404 , gin.H {
68+ "errors" : []gin.H {
69+ {
70+ "code" : "DENIED" ,
71+ "message" : "authentication required" ,
72+ "detail" : "Uploaded asset not found" ,
73+ },
74+ },
75+ })
4476 return
4577 }
4678
4779 fileData , err := s .Storage .GetFile (s .PackageFilename (asset .Digest ))
4880 if err != nil || fileData == nil {
49- c .JSON (404 , gin.H {"error" : "Not Found" })
81+ c .JSON (404 , gin.H {
82+ "errors" : []gin.H {
83+ {
84+ "code" : "DENIED" ,
85+ "message" : "authentication required" ,
86+ "detail" : "Not Found" ,
87+ },
88+ },
89+ })
5090 return
5191 }
5292
0 commit comments