mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 11:57:02 +00:00
make macros even faster and smart catch common :string and do not execute anything at all if not really needed, more clean code as well
Former-commit-id: 589c23d1f92cf36b7677dfe78b60d51252c979fb
This commit is contained in:
@@ -65,6 +65,24 @@ func main() {
|
||||
return fmt.Sprintf("Value of the parameters are: %s:%d\n", myparam1, myparam2)
|
||||
}))
|
||||
|
||||
app.Get("/test_string/{myparam1}/{myparam2 prefix(a)}", func(ctx context.Context) {
|
||||
var (
|
||||
myparam1 = ctx.Params().Get("myparam1")
|
||||
myparam2 = ctx.Params().Get("myparam2")
|
||||
)
|
||||
|
||||
ctx.Writef("myparam1: %s | myparam2: %s", myparam1, myparam2)
|
||||
})
|
||||
|
||||
app.Get("/test_string2/{myparam1}/{myparam2}", func(ctx context.Context) {
|
||||
var (
|
||||
myparam1 = ctx.Params().Get("myparam1")
|
||||
myparam2 = ctx.Params().Get("myparam2")
|
||||
)
|
||||
|
||||
ctx.Writef("myparam1: %s | myparam2: %s", myparam1, myparam2)
|
||||
})
|
||||
|
||||
app.Get("test_uint64/{myparam1:string}/{myparam2:uint64}", func(ctx context.Context) {
|
||||
// works: ctx.Writef("Value of the parameter is: %s\n", ctx.Params().Get("myparam"))
|
||||
// but better and faster because the macro converts the string to uint64 automatically:
|
||||
|
||||
Reference in New Issue
Block a user