Skip to content

gernest/helen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

helen Build Status GoDoc Coverage Status

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
  • 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

package main

import (
	"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,

	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

GoDoc

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 Ernest geofreyernest@live.com

Twitter : @gernesti

Facebook : Geofrey Ernest

Licence

This project is released under the MIT licence. See LICENCE for more details.

About

Handle your static assets with care

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages