An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# StaticBin [![wercker status](https://app.wercker.com/status/b026f59be5b3fb82aef510bfc46984f0/s "wercker status")](https://app.wercker.com/project/bykey/b026f59be5b3fb82aef510bfc46984f0) [![GoDoc](https://godoc.org/github.com/olebedev/staticbin?status.png)](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")
}
```