From b2c38ef474939d9d01e0039383254bf675aa4e5e Mon Sep 17 00:00:00 2001 From: alessio Date: Tue, 6 Sep 2016 02:31:44 +0200 Subject: [PATCH] bindata render --- server/assets/index.html | 1 + server/main.go | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 server/assets/index.html diff --git a/server/assets/index.html b/server/assets/index.html new file mode 100644 index 0000000..0a90125 --- /dev/null +++ b/server/assets/index.html @@ -0,0 +1 @@ +Testing \ No newline at end of file diff --git a/server/main.go b/server/main.go index ca3105f..1ff6f8b 100644 --- a/server/main.go +++ b/server/main.go @@ -3,13 +3,27 @@ package server import ( "github.com/labstack/echo" "github.com/labstack/echo/engine/standard" + "github.com/labstack/echo/middleware" "net/http" ) +func render(c echo.Context, path string) error{ + data, err := Asset(path) + if err != nil { + return echo.NewHTTPError(http.StatusNotFound) + } + rs := c.Response() + rs.Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8) + rs.WriteHeader(http.StatusOK) + rs.Write(data) + return nil +} + func init() { e := echo.New() + e.Use(middleware.Gzip()) e.GET("/", func(c echo.Context) error { - return c.String(http.StatusOK, "Hi Realize") + return render(c, "server/assets/index.html") }) go e.Run(standard.New(":5000")) }