Skip to content

Instantly share code, notes, and snippets.

@ykyuen
Last active November 19, 2018 06:09
Show Gist options
  • Save ykyuen/d22df3ea67a79ce947a86d48ef759cb0 to your computer and use it in GitHub Desktop.
Save ykyuen/d22df3ea67a79ce947a86d48ef759cb0 to your computer and use it in GitHub Desktop.
setup-nested-html-template-in-go-echo-web-framework-03
package main
import (
"net/http"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.GET("/json", func(c echo.Context) error {
return c.JSONBlob(
http.StatusOK,
[]byte(`{ "id": "1", "msg": "Hello, Boatswain!" }`),
)
})
e.GET("/html", func(c echo.Context) error {
return c.HTML(
http.StatusOK,
"<h1>Hello, Boatswain!</h1>",
)
})
e.Logger.Fatal(e.Start(":1323"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment