mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 11:57:02 +00:00
add uint8 parameter type, and mvc and hero - this commit may be a point of tutorial on how to add a completely new type from scratch to the hero for future contributors
Former-commit-id: dc7a7e6c97ef0c644a22e92072e4bdb98ae10582
This commit is contained in:
@@ -48,6 +48,13 @@ func main() {
|
||||
// -9223372036854775808 to 9223372036854775807
|
||||
//
|
||||
// +------------------------+
|
||||
// | {param:uint8} |
|
||||
// +------------------------+
|
||||
// uint8 type
|
||||
// 0 to 255
|
||||
//
|
||||
//
|
||||
// +------------------------+
|
||||
// | {param:uint64} |
|
||||
// +------------------------+
|
||||
// uint64 type
|
||||
@@ -146,6 +153,12 @@ func main() {
|
||||
ctx.Writef("Hello id: %d looking for friend id: ", id, friendid)
|
||||
}) // this will throw e 504 error code instead of 404 if all route's macros not passed.
|
||||
|
||||
// :uint8 0 to 255.
|
||||
app.Get("/ages/{age:uint8 else 400}", func(ctx iris.Context) {
|
||||
age, _ := ctx.Params().GetUint8("age")
|
||||
ctx.Writef("age selected: %d", age)
|
||||
})
|
||||
|
||||
// Another example using a custom regexp and any custom logic.
|
||||
latLonExpr := "^-?[0-9]{1,3}(?:\\.[0-9]{1,10})?$"
|
||||
latLonRegex, err := regexp.Compile(latLonExpr)
|
||||
|
||||
Reference in New Issue
Block a user