HTTP Responses
Responses from HTTP endpoints can return data in headers and in the body.
The Content-Type header specifies the format of data in the body. The following table describes common values for this header, but many more are possible.
Format | Content-Type Value |
|---|---|
text | text/plain |
JSON | application/json |
HTML | text/html |
image | image/jpeg, image/png, etc. |
Hono functions that define endpoints must return a Response object. These functions are passed a Context object. Typically, they call a method on the Context object and then return the results as a Response object. Results include text, json, html, and notFound. The methods also set the Content-Type header to the appropriate value and set the contents of the response body.
The argument to the html method ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access