Rendering

As mentioned previously, the job of a web application or an API is to create an HTTP response message, given an HTTP request message. Echo has a really nice facility to help us render responses from our handlers and middleware functions. echo.Context has methods which perform all of the heavy hitting for rendering responses back to the caller. As seen in prior examples, there is a JSON method on the Echo Context which allows for rendering of a JSON payload back to the caller. The following is a list of supported rendering capabilities within Echo:

  • HTML: Render an HTML response:

    • HTMLBlob: Render a preformed HTML response

  • JSON: Render a JSON response, converting the variable into JSON based on the struct tags of the variable: ...

Get Echo Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.