Compare commits

..

3 commits

Author SHA1 Message Date
WJQSERVER
e10c20c5d6
Merge pull request #40 from infinite-iroha/dev
add Text
2025-07-18 15:30:20 +08:00
wjqserver
b06b4a227f update deps 2025-07-18 15:30:03 +08:00
wjqserver
ad167b6646 add Text 2025-07-18 15:26:43 +08:00

View file

@ -271,6 +271,13 @@ func (c *Context) String(code int, format string, values ...interface{}) {
c.Writer.Write([]byte(fmt.Sprintf(format, values...))) c.Writer.Write([]byte(fmt.Sprintf(format, values...)))
} }
// Text 向响应写入无需格式化的string
func (c *Context) Text(code int, text string) {
c.Writer.Header().Set("Content-Type", "text/plain; charset=utf-8")
c.Writer.WriteHeader(code)
c.Writer.Write([]byte(text))
}
// JSON 向响应写入 JSON 数据 // JSON 向响应写入 JSON 数据
// 设置 Content-Type 为 application/json // 设置 Content-Type 为 application/json
func (c *Context) JSON(code int, obj interface{}) { func (c *Context) JSON(code int, obj interface{}) {