From 2c33ffbe752ddb3349d3ff25cf7840f6904ead60 Mon Sep 17 00:00:00 2001 From: Erik Bos Date: Wed, 8 Dec 2021 23:04:28 +0100 Subject: [PATCH] Abort Gin request in case middleware function called abort --- pkg/codegen/templates/gin/gin-wrappers.tmpl | 3 +++ pkg/codegen/templates/templates.gen.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/codegen/templates/gin/gin-wrappers.tmpl b/pkg/codegen/templates/gin/gin-wrappers.tmpl index 6eb787c097..0a96cf86d3 100644 --- a/pkg/codegen/templates/gin/gin-wrappers.tmpl +++ b/pkg/codegen/templates/gin/gin-wrappers.tmpl @@ -168,6 +168,9 @@ func (siw *ServerInterfaceWrapper) {{$opid}}(c *gin.Context) { for _, middleware := range siw.HandlerMiddlewares { middleware(c) } + if c.IsAborted() { + return + } siw.Handler.{{.OperationId}}(c{{genParamNames .PathParams}}{{if .RequiresParamObject}}, params{{end}}) } diff --git a/pkg/codegen/templates/templates.gen.go b/pkg/codegen/templates/templates.gen.go index a7211f9b28..d50b81da18 100644 --- a/pkg/codegen/templates/templates.gen.go +++ b/pkg/codegen/templates/templates.gen.go @@ -1175,6 +1175,9 @@ func (siw *ServerInterfaceWrapper) {{$opid}}(c *gin.Context) { for _, middleware := range siw.HandlerMiddlewares { middleware(c) } + if c.IsAborted() { + return + } siw.Handler.{{.OperationId}}(c{{genParamNames .PathParams}}{{if .RequiresParamObject}}, params{{end}}) }