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

add new ':email' path parameter and revert the jsoniter removal

This commit is contained in:
Gerasimos (Makis) Maropoulos
2021-10-13 16:22:22 +03:00
parent a9b97e005a
commit bf54d33a3e
15 changed files with 179 additions and 101 deletions

View File

@@ -172,6 +172,19 @@ func main() {
ctx.WriteString(id)
})
// +------------------------+
// | {param:email} |
// +------------------------+
// Email + mx look uppath parameter validation.
// Note that, you can also use the simplier ":mail" to accept any domain email.
// http://localhost:8080/user/email/kataras2006@hotmail.com -> OK
// http://localhost:8080/user/email/b-c@ -> NOT FOUND
app.Get("/user/email/{user_email:email}", func(ctx iris.Context) {
email := ctx.Params().Get("user_email")
ctx.WriteString(email)
})
// you can use the "string" type which is valid for a single path parameter that can be anything.
app.Get("/username/{name}", func(ctx iris.Context) {
ctx.Writef("Hello %s", ctx.Params().Get("name"))