是的,你可以这样做。只需从处理程序中返回即可。而您要执行的后台作业,则应将其放在新的goroutine中。
请注意,可以将连接和/或请求放回池中,但这无关紧要,客户端将看到为请求提供服务已结束。您实现了您想要的。
像这样:
func Test(c *gin.Context) { c.String(200, "ok") // By returning from this function, response will be sent to the client // and the connection to the client will be closed // Started goroutine will live on, of course: go func() { // This function will continue to execute... }()}


