1
0
mirror of https://github.com/labstack/echo.git synced 2025-04-15 11:56:51 +02:00
echo/recipes/rice/server.go
Carlos Alexandro Becker 7a7ceeb9c4 Added go.rice recipe
2015-10-14 00:59:49 -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")
}