Implemented the io.Writer interface

This commit is contained in:
2024-03-13 22:49:57 +01:00
parent c13dbc55d2
commit 80dc3f87eb
2 changed files with 12 additions and 0 deletions

View File

@ -26,6 +26,7 @@ type Context interface {
ResponseHeader(key string) string
Status(status int) Context
String(string) error
Write([]byte) (int, error)
}
// ctx represents a request & response context.
@ -142,6 +143,11 @@ func (ctx *ctx) String(body string) error {
return ctx.Bytes(slice)
}
// Write implements the io.Writer interface.
func (ctx *ctx) Write(body []byte) (int, error) {
return ctx.response.Write(body)
}
// addParameter adds a new parameter to the context.
func (ctx *ctx) addParameter(name string, value string) {
ctx.paramNames[ctx.paramCount] = name