nezha/pkg/utils/gin_writer_wrapper.go

21 lines
369 B
Go
Raw Normal View History

package utils
import "github.com/gin-gonic/gin"
type GinCustomWriter struct {
gin.ResponseWriter
customCode int
}
func NewGinCustomWriter(c *gin.Context, code int) *GinCustomWriter {
return &GinCustomWriter{
ResponseWriter: c.Writer,
customCode: code,
}
}
func (w *GinCustomWriter) WriteHeader(code int) {
w.ResponseWriter.WriteHeader(w.customCode)
}