1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-26 20:54:00 +02:00
echo/recipes/embed-resources/rice.go
Carlos Alexandro Becker 630eb193b9 cr
2015-10-17 22:05:32 -03:00

27 lines
643 B
Go

package main
import (
"net/http"
"github.com/GeertJohan/go.rice"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
// the file server for rice. "app" is the folder where the files come from.
assetHandler := http.FileServer(rice.MustFindBox("app").HTTPBox())
// serves the index.html from rice
e.Get("/", func(c *echo.Context) error {
assetHandler.ServeHTTP(c.Response().Writer(), c.Request())
return nil
})
// servers other static files
e.Get("/static/*", func(c *echo.Context) error {
http.StripPrefix("/static/", assetHandler).
ServeHTTP(c.Response().Writer(), c.Request())
return nil
})
e.Run(":3000")
}