nezha/pkg/utils/gin_writer_wrapper.go
naiba f6683adb70
Some checks failed
Contributors / contributors (push) Waiting to run
Sync / sync-to-jihulab (push) Waiting to run
Run Tests / tests (macos) (push) Waiting to run
Run Tests / tests (ubuntu) (push) Waiting to run
Run Tests / tests (windows) (push) Waiting to run
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
feat: implement client-side status code handling
2025-01-05 23:53:04 +08:00

21 lines
369 B
Go

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)
}