|  | @@ -1,41 +0,0 @@
 | 
	
		
			
			| 1 |  | -package utils
 | 
	
		
			
			| 2 |  | -
 | 
	
		
			
			| 3 |  | -import (
 | 
	
		
			
			| 4 |  | -	"net/http"
 | 
	
		
			
			| 5 |  | -
 | 
	
		
			
			| 6 |  | -	"github.com/gin-gonic/gin"
 | 
	
		
			
			| 7 |  | -)
 | 
	
		
			
			| 8 |  | -
 | 
	
		
			
			| 9 |  | -func Must(i interface{}, err error) interface{} {
 | 
	
		
			
			| 10 |  | -	if err != nil {
 | 
	
		
			
			| 11 |  | -		panic(err)
 | 
	
		
			
			| 12 |  | -	}
 | 
	
		
			
			| 13 |  | -
 | 
	
		
			
			| 14 |  | -	return i
 | 
	
		
			
			| 15 |  | -}
 | 
	
		
			
			| 16 |  | -
 | 
	
		
			
			| 17 |  | -func Error(ctx *gin.Context, err error) error {
 | 
	
		
			
			| 18 |  | -	if err != nil {
 | 
	
		
			
			| 19 |  | -		ctx.JSON(http.StatusBadRequest, gin.H{"info": err.Error()})
 | 
	
		
			
			| 20 |  | -		return err
 | 
	
		
			
			| 21 |  | -	}
 | 
	
		
			
			| 22 |  | -	return nil
 | 
	
		
			
			| 23 |  | -}
 | 
	
		
			
			| 24 |  | -
 | 
	
		
			
			| 25 |  | -func Bool(ctx *gin.Context, boolean bool) bool {
 | 
	
		
			
			| 26 |  | -	if !boolean {
 | 
	
		
			
			| 27 |  | -		ctx.JSON(http.StatusBadRequest, gin.H{"info": "validate failed"})
 | 
	
		
			
			| 28 |  | -		return !boolean
 | 
	
		
			
			| 29 |  | -	}
 | 
	
		
			
			| 30 |  | -	return boolean
 | 
	
		
			
			| 31 |  | -}
 | 
	
		
			
			| 32 |  | -
 | 
	
		
			
			| 33 |  | -func Success(ctx *gin.Context, data ...interface{}) {
 | 
	
		
			
			| 34 |  | -	response := gin.H{
 | 
	
		
			
			| 35 |  | -		"info": "success",
 | 
	
		
			
			| 36 |  | -	}
 | 
	
		
			
			| 37 |  | -	if len(data) > 0 {
 | 
	
		
			
			| 38 |  | -		response["data"] = data[0]
 | 
	
		
			
			| 39 |  | -	}
 | 
	
		
			
			| 40 |  | -	ctx.JSON(http.StatusOK, response)
 | 
	
		
			
			| 41 |  | -}
 |