1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

various improvements and new 'UseOnce' method - read HISTORY.md

This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-08-06 03:35:58 +03:00
parent 5d480dc801
commit 46a3a99adf
20 changed files with 147 additions and 221 deletions

View File

@@ -44,6 +44,22 @@ func Match(ctx *context.Context, expectedVersion string) bool {
return true
}
// Handler returns a handler which stop the execution
// when the given "version" does not match with the requested one.
func Handler(version string) context.Handler {
return func(ctx *context.Context) {
if !Match(ctx, version) {
// Any overlapped handler
// can just clear the status code
// and the error to ignore this (see `NewGroup`).
NotFoundHandler(ctx)
return
}
ctx.Next()
}
}
// Map is a map of versions targets to a handlers,
// a handler per version or constraint, the key can be something like ">1, <=2" or just "1".
type Map map[string]context.Handler