Package martini_sandwich is a martini-adapter for sandwich that provides the martini request parameters to the middleware stack.

The Middleware implementation in this package is identical to the normal sandwich.Middleware except:

- it provides the martini.Params type by default for accessing route parameters
- it has a .H field for getting the martini handler easily.

Here's a simple example of using this:

s := martini_sandwich.TheUsual().Provide(...).With(...)
m := martini.Classic()
m.Get("/user/:id/", s.Provide(userdb).With(getUser).H) // <-- Note the .H

func getUser(w http.ResponseWriter, p martini.Params, udb UserDb) error {
    userId := p["id"]
    user, err := udb.Lookup(userId)
    if err != nil {
        return err // or wrap with sandwich.Error{...}
    return json.NewEncoder(w).Encode(user)

Imports 3 package(s) ΒΆ