replace AbortWithError calls by custom function that sets the content type correctly

This commit is contained in:
Markus Muellner
2022-10-26 17:13:37 +02:00
committed by Benj Fassbind
parent 81582bffd2
commit ecc41f0c0f
11 changed files with 116 additions and 111 deletions
+5 -5
View File
@@ -38,7 +38,7 @@ func apiGPGAddKey(c *gin.Context) {
var tempdir string
tempdir, err = os.MkdirTemp(os.TempDir(), "aptly")
if err != nil {
c.AbortWithError(400, err)
AbortWithJSONError(c, 400, err)
return
}
defer os.RemoveAll(tempdir)
@@ -46,11 +46,11 @@ func apiGPGAddKey(c *gin.Context) {
keypath := filepath.Join(tempdir, "key")
keyfile, e := os.Create(keypath)
if e != nil {
c.AbortWithError(400, e)
AbortWithJSONError(c, 400, e)
return
}
if _, e = keyfile.WriteString(b.GpgKeyArmor); e != nil {
c.AbortWithError(400, e)
AbortWithJSONError(c, 400, e)
}
args = append(args, "--import", keypath)
@@ -64,7 +64,7 @@ func apiGPGAddKey(c *gin.Context) {
finder := pgp.GPG1Finder()
gpg, _, err := finder.FindGPG()
if err != nil {
c.AbortWithError(400, err)
AbortWithJSONError(c, 400, err)
return
}
@@ -75,7 +75,7 @@ func apiGPGAddKey(c *gin.Context) {
fmt.Printf("running %s %s\n", gpg, strings.Join(args, " "))
cmd.Stdout = os.Stdout
if err = cmd.Run(); err != nil {
c.AbortWithError(400, err)
AbortWithJSONError(c, 400, err)
return
}