mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 19:36:36 +08:00
@@ -0,0 +1,22 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/service"
|
||||
)
|
||||
|
||||
func writeSubscriptionConflict(c *gin.Context, err error) bool {
|
||||
if !errors.Is(err, service.ErrSubscriptionAlreadyExists) {
|
||||
return false
|
||||
}
|
||||
body := gin.H{"error": "subscription already exists"}
|
||||
if existingID := service.SubscriptionAlreadyExistsID(err); existingID != "" {
|
||||
body["existing_id"] = existingID
|
||||
}
|
||||
c.JSON(http.StatusConflict, body)
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user