https://github.com/code-hex/echo-static
Static middleware for echo web framework(golang)
https://github.com/code-hex/echo-static
Last synced: 6 months ago
JSON representation
Static middleware for echo web framework(golang)
- Host: GitHub
- URL: https://github.com/code-hex/echo-static
- Owner: Code-Hex
- License: mit
- Created: 2017-01-12T08:32:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-13T09:21:51.000Z (almost 9 years ago)
- Last Synced: 2025-03-31T00:06:44.187Z (9 months ago)
- Language: Go
- Size: 9.77 KB
- Stars: 19
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
echo-static
====
[](https://travis-ci.org/Code-Hex/echo-static)
[](https://coveralls.io/github/Code-Hex/echo-static?branch=master)
[](https://goreportcard.com/report/github.com/Code-Hex/echo-static)
[](https://godoc.org/github.com/Code-Hex/echo-static)
[](LICENSE)
# SYNOPSIS
```go
package main
import (
static "github.com/Code-Hex/echo-static"
assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/labstack/echo"
)
func main() {
e := echo.New()
e.Use(static.ServeRoot("/static", NewAssets("assets")))
e.GET("/ping", func(c echo.Context) error {
return c.String(200, "test")
})
// Listen and Server in 0.0.0.0:8080
e.Start(":8080")
}
func NewAssets(root string) *assetfs.AssetFS {
return &assetfs.AssetFS{
Asset: Asset,
AssetDir: AssetDir,
AssetInfo: AssetInfo,
Prefix: root,
}
}
```
and put your asset file in the `assets` directory and execute the following code before compile it.
go-bindata -o bindata.go assets/...
# DESCRIPTION
echo-static is File server middleware for [go-bindata](https://github.com/jteeuwen/go-bindata) and [echo](https://github.com/labstack/echo).
# INSTALLATION
go get github.com/Code-Hex/echo-static
# AUTHOR
[codehex](https://twitter.com/CodeHex)