Implemented the io.Writer interface

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

View File

@ -26,6 +26,11 @@ func TestRouter(t *testing.T) {
return ctx.String("Hello")
})
s.Get("/write", func(ctx server.Context) error {
_, err := io.WriteString(ctx, "Hello")
return err
})
s.Get("/error", func(ctx server.Context) error {
return ctx.Status(http.StatusUnauthorized).Error("Not logged in")
})
@ -94,6 +99,7 @@ func TestRouter(t *testing.T) {
{Method: "GET", URL: "/response/header", Status: http.StatusOK, Body: "text/plain"},
{Method: "GET", URL: "/reader", Status: http.StatusOK, Body: "Hello"},
{Method: "GET", URL: "/string", Status: http.StatusOK, Body: "Hello"},
{Method: "GET", URL: "/write", Status: http.StatusOK, Body: "Hello"},
{Method: "GET", URL: "/blog/testing-my-router", Status: http.StatusOK, Body: "testing-my-router"},
{Method: "GET", URL: "/missing-parameter", Status: http.StatusOK, Body: ""},
{Method: "POST", URL: "/", Status: http.StatusOK, Body: "Post"},