https://github.com/gernest/helen
Handle your static assets with care
https://github.com/gernest/helen
Last synced: 6 months ago
JSON representation
Handle your static assets with care
- Host: GitHub
- URL: https://github.com/gernest/helen
- Owner: gernest
- License: mit
- Created: 2015-10-11T17:02:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-31T18:00:39.000Z (over 9 years ago)
- Last Synced: 2023-08-05T15:23:03.373Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 18
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# helen [](https://travis-ci.org/gernest/helen) [](https://godoc.org/github.com/gernest/helen) [](https://coveralls.io/github/gernest/helen?branch=master)
Helen is the static assets handler for golang based web applications. Helen simply handles serving your static files that is javascript, stylesheets and images.
# features
* Fast
* Javascript and Stylesheets minifications
* support
- [gorilla mux](https://github.com/gorilla/mux)
- [echo](https://github.com/labstack/echo)
- [http.ServeMux](https://godoc.org/net/http#ServeMux)
- [httrouter](https://github.com/julienschmidt/httprouter)[coming soon]
* middlewares. You can chain any alice compatible middlwares.# Motivation
After using different golang frameworks and libraries for building web applications, I usually came across the need to serve my static files and heck It is a bit complicated.
So helen, is a simple aproach to handle static assets. Helen supports different golang routers, you can use this as a way to remind youself how you can handle static assets for your favorite router.
# Installation
go get github.com/gernest/helen
# How to use
```go
package mainimport (
"log"
"net/http""github.com/gernest/helen"
"github.com/gorilla/mux"
)func main() {
// Create the instance of your router
server := mux.NewRouter()// Create a new helen.Static instance. We are passing "static" as the directory
// we want to serve static content from.
static := helen.NewStatic("fixtures")// We bind anything matching /static/ route to our static handler
static.Bind("/static/", server)// You can register other handlers to your server or whatever you want to do with it.
log.Fatal(http.ListenAndServe(":8000", server))
}```
In this example we will be sriving contents of the fixtures directory as static files.
This example uses `gorilla mux` router. Note that you can bind the helen handler at any point of your application. This example also works for all the supported routers.
# Middlewares
You can add any alice compatible middlewares to the `*Static` instance. If you want gzip compression and you have a wonderful implementation called `gzipMe`.
Then,
```go
static:=helen.Static("static")
static.Use(gzipMe)
```Will register your middleware. Not that you can pass whatever number of middlewares you want to the `Static.Use` method.
# Documentation
[](https://godoc.org/github.com/gernest/helen)# TODO
- Optimize memory usage
- Write benchmarks# Contributing
Start with clicking the star button to make the author and his neighbors happy. Then fork the repository and submit a pull request for whatever change you want to be added to this project.
If you have any questions, just open an issue.
# Author
Geofrey ErnestTwitter : [@gernesti](https://twitter.com/gernesti)
Facebook : [Geofrey Ernest](https://www.facebook.com/geofrey.ernest.35)
# Licence
This project is released under the MIT licence. See [LICENCE](LICENCE) for more details.