bindata render
This commit is contained in:
parent
1cc2e64e5c
commit
b2c38ef474
|
@ -0,0 +1 @@
|
|||
Testing
|
|
@ -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"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue