func main() {
r := gin.Default()
r.GET("/test", func(c *gin.Context) {
if someCondition {
c.JSON(http.StatusInternalServerError, gin.H{"error": true})
SomeThing
}
c.JSON(http.StatusOK, gin.H{"live": true})
})
r.Run()
}
I want to prevent processing of last line (c.JSON(http.StatusOK, gin.H{"live": true})
) if SomeThing
was processed.
Comment From: Rorke76753
just add return
in your if block