Micro & pluggable web framework for Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
496 B

// Copyright 2015 The Tango Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package tango
import (
"strings"
)
// Prefix provides a middleware to wrap another middleware with a prefix URL
// TODO: regex prefix
func Prefix(prefix string, handler Handler) HandlerFunc {
return func(ctx *Context) {
if strings.HasPrefix(ctx.Req().URL.Path, prefix) {
handler.Handle(ctx)
return
}
ctx.Next()
}
}