working commit
This commit is contained in:
@@ -124,7 +124,7 @@ func (rctx *Context) SetStatus(httpStatus int) {
|
||||
}
|
||||
|
||||
func (rctx *Context) SendJSON(statusCode int, payload any) {
|
||||
|
||||
rctx.StatusCode = statusCode
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
json.NewEncoder(buffer).Encode(payload)
|
||||
rctx.Writer.Header().Set("Content-Type", "application/json")
|
||||
@@ -135,6 +135,7 @@ func (rctx *Context) SendJSON(statusCode int, payload any) {
|
||||
}
|
||||
|
||||
func (rctx *Context) SendText(statusCode int, payload string) {
|
||||
rctx.StatusCode = statusCode
|
||||
size := strconv.FormatInt(int64(len(payload)), 10)
|
||||
rctx.Writer.Header().Set("Content-Type", "text/plain")
|
||||
rctx.Writer.Header().Set("Content-Length", size)
|
||||
@@ -143,6 +144,7 @@ func (rctx *Context) SendText(statusCode int, payload string) {
|
||||
}
|
||||
|
||||
func (rctx *Context) SendBytes(statusCode int, ctype string, payload []byte) {
|
||||
rctx.StatusCode = statusCode
|
||||
size := strconv.FormatInt(int64(len(payload)), 10)
|
||||
rctx.Writer.Header().Set("Content-Type", ctype)
|
||||
rctx.Writer.Header().Set("Content-Length", size)
|
||||
|
||||
Reference in New Issue
Block a user