发生错误时如何关闭websockethandle

func WsConnectionHandle(ctx *gin.Context){
    ws, err := upgrader.Upgrade(ctx.Writer, ctx.Request, nil)
    if err != nil{
        config.Error.Println("connect err", err.Error())
        //config.Error.Fatalln("connect err")
        ctx.Abort() 
    }
    ...

when I use ctx.Abort() it still ran the code below, and if I use Fatalln, my main process will stop~

and this is my router

gin.SetMode(gin.ReleaseMode)
route := gin.Default()
resource.User(route.Group("/api/user"))
resource.KingAngAngle(route.Group("/api/king-and-angle", resource.JWTAuth()))
resource.Blessing(route.Group("/api/blessing", resource.JWTAuth()))
route.GET("/ws", chat.WsConnectionHandle)

Well, ctx.Abort() is a function call, nothing more, nothing less. It doesn't affect the flow/scope of the function in which it's called. If you don't want to execute anything after calling ctx.Abort(), then just return to exit the function:

if err != nil {
    log.Printf("some error: %+v", err)
    ctx.Abort()
    return // exit function
}