codegangsta/martini — pull request #90 by Archs (2013-11-28 07:08:55+00:00)
Title: Any method routing support for Martini

A new method `Any` is introduced to route certain urls of any methods to a `martini.Handler`.

```go
// Any adds a route for any HTTP method request to the specified matching pattern.
Any(string, ...Handler)
```

With `Any` we could fully install martini upon martini, and thus other frameworks like `web.go` could be installed upon martini the same way. :)

~~~ go
package main

import (
"github.com/Archs/martini"
"github.com/Archs/martini-contrib/strip"
"github.com/Archs/martini-contrib/web"
)

func main() {
m := martini.Classic()

m2 := martini.Classic()
m2.Use(web.ContextWithCookieSecret(""))
m2.Get("/", func() string {
return "Hello World from 2nd martini"
})

m2.Get("/foo", func(ctx *web.Context) {
ctx.ContentType("text/html")
ctx.WriteString(html)
})

m2.Post("/foo", func() string {
return "Welcome to Post"
})

m.Get("/", func() string {
return "Hello World from 1st martini"
})
// Any to do the dirty tricks.
m.Any("/2ndMartini/.*", strip.Prefix("/2ndMartini"), m2.ServeHTTP)

m.Run()
}

const (
html = `
Hello Foo

Inpu:

`
)
~~~