https://github.com/olebedev/staticbin
Gin middleware/handler for serving static files from binary data
https://github.com/olebedev/staticbin
Last synced: 10 months ago
JSON representation
Gin middleware/handler for serving static files from binary data
- Host: GitHub
- URL: https://github.com/olebedev/staticbin
- Owner: olebedev
- License: mit
- Created: 2015-01-01T17:45:05.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-08T02:16:58.000Z (over 11 years ago)
- Last Synced: 2025-08-13T22:32:54.521Z (11 months ago)
- Language: Go
- Homepage:
- Size: 191 KB
- Stars: 42
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StaticBin [](https://app.wercker.com/project/bykey/b026f59be5b3fb82aef510bfc46984f0) [](https://godoc.org/github.com/olebedev/staticbin)
[Gin](https://github.com/gin-gonic/gin) middleware/handler for serving static files from binary data.
## Usage
```go
package main
import (
"github.com/gin-gonic/gin"
"github.com/olebedev/staticbin"
)
func main() {
r := gin.New() // without any middlewares
// Serves the "static" directory's files from binary data.
// You have to pass the "Asset" function generated by
// go-bindata (https://github.com/jteeuwen/go-bindata).
r.Use(staticbin.Static(Asset, staticbin.Options{
// Dir prefix will be trimmed. It needs to separate namespace.
Dir: "/static",
}))
r.Get("/", func() string {
return "Hello world!"
})
r.Run(":8080")
}
```