Created
April 11, 2014 20:11
-
-
Save sevkin/10497657 to your computer and use it in GitHub Desktop.
custom middleware for martini
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Vermut() *martini.ClassicMartini { | |
r := martini.NewRouter() | |
m := martini.New() | |
m.Use(martini.Logger()) | |
m.Use(martini.Recovery()) | |
// pass cached images to thumbnailer | |
m.Use(NewThumbnailer("public")) | |
cache := martini.NewRouter() | |
cache.Group("/cache", cacheHandler) | |
cache.NotFound(func() {}) | |
m.Use(cache.Handle) | |
// then serve generated (and not) thumbs by static | |
m.Use(martini.Static("public")) | |
m.MapTo(r, (*martini.Routes)(nil)) | |
m.Action(r.Handle) | |
return &martini.ClassicMartini{m, r} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment