bindata render

This commit is contained in:
alessio 2016-09-06 02:31:44 +02:00
parent 1cc2e64e5c
commit b2c38ef474
2 changed files with 16 additions and 1 deletions

1
server/assets/index.html Normal file
View File

@ -0,0 +1 @@
Testing

View File

@ -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"))
}