SimpleCloudNotifier/server/common/ginresp/wrapper.go

22 lines
328 B
Go
Raw Normal View History

2022-11-13 19:17:07 +01:00
package ginresp
import "github.com/gin-gonic/gin"
type WHandlerFunc func(*gin.Context) HTTPResponse
func Wrap(fn WHandlerFunc) gin.HandlerFunc {
return func(context *gin.Context) {
wrap := fn(context)
if context.Writer.Written() {
panic("Writing in WrapperFunc is not supported")
}
wrap.Write(context)
}
}