-
Hi maintainers. I want to return the error response which Content-Type is text/html. I try the followings, but this returns errors. Thanks! code: // design
Error("InternalServerError", String)
HTTP(func() {
GET("test")
Response("InternalServerError", StatusInternalServerError, func() { ContentType("text/html") })
})
// service
return nil, test.InternalServerError("<p>internal server error</p>") error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hello, the |
Beta Was this translation helpful? Give feedback.
Hello, the
text/html
encoder only supports strings or slice of bytes, it doesn't know how to serialize an arbitrary object into HTML (there really isn't a well defined way to do that in general). You can either change the error type to be a string or provide your own encoder that knows how to serialize the error object into HTML.