1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 18:07:01 +00:00

add iris.TrimParamFilePart

read more at: #2024
This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-12-24 05:04:16 +02:00
parent 85fd5ead04
commit 29c8f44c93
6 changed files with 144 additions and 3 deletions

View File

@@ -352,6 +352,17 @@ func main() {
}) // for wildcard path (any number of path segments) without validation you can use:
// /myfiles/*
// http://localhost:8080/trimmed/42.html
app.Get("/trimmed/{uid:string regexp(^[0-9]{1,20}.html$)}", iris.TrimParamFilePart, func(ctx iris.Context) {
//
// The above line is useless now that we've registered the TrimParamFilePart middleware:
// uid := ctx.Params().GetTrimFileUint64("uid")
// TrimParamFilePart can be registered to a Party (group of routes) too.
uid := ctx.Params().GetUint64Default("uid", 0)
ctx.Writef("Param value: %d\n", uid)
})
// "{param}"'s performance is exactly the same of ":param"'s.
// alternatives -> ":param" for single path parameter and "*" for wildcard path parameter.