From 34ab8862bda1505883db5ed6d01c8550f478b9f6 Mon Sep 17 00:00:00 2001 From: xgfone Date: Mon, 23 Dec 2024 15:36:23 +0800 Subject: [PATCH] changed: remove args from BlobText, Text, HTML of Context --- http/reqresp/context.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/http/reqresp/context.go b/http/reqresp/context.go index 52d1773..971c128 100644 --- a/http/reqresp/context.go +++ b/http/reqresp/context.go @@ -499,29 +499,24 @@ func (c *Context) Blob(code int, contentType string, data []byte) { } // BlobText sends a string blob response with the status code and the content type. -func (c *Context) BlobText(code int, contentType string, format string, args ...any) { +func (c *Context) BlobText(code int, contentType string, text string) { c.SetContentType(contentType) c.WriteHeader(code) - if len(format) > 0 { - var err error - if len(args) > 0 { - _, err = fmt.Fprintf(c.ResponseWriter, format, args...) - } else { - _, err = io.WriteString(c.ResponseWriter, format) - } + if len(text) > 0 { + _, err := io.WriteString(c.ResponseWriter, text) c.AppendError(err) } } // Text sends a string response with the status code. -func (c *Context) Text(code int, format string, args ...any) { - c.BlobText(code, header.MIMETextPlainCharsetUTF8, format, args...) +func (c *Context) Text(code int, text string) { + c.BlobText(code, header.MIMETextPlainCharsetUTF8, text) } // HTML sends a HTML response with the status code. -func (c *Context) HTML(code int, format string, args ...any) { - c.BlobText(code, header.MIMETextHTMLCharsetUTF8, format, args...) +func (c *Context) HTML(code int, text string) { + c.BlobText(code, header.MIMETextHTMLCharsetUTF8, text) } // JSON sends a JSON response with the status code.