Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (17 sloc) 0.44 kb
package mango
import (
"regexp"
)
func Routing(routes map[string]App) Middleware {
return func(env Env, app App) (Status, Headers, Body) {
path := []byte(env.Request().URL.Path)
for regex, stack := range routes {
if matched, err := regexp.Match(regex, path); matched && err == nil {
// Matched a route return it
return stack(env)
}
}
// didn't match any of the other routes. pass upstream.
return app(env)
}
}
Jump to Line
Something went wrong with that request. Please try again.