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

Bet that many of you didn't know that Iris could handle regexp-based path parameters with ease :)

Former-commit-id: d2c5564cfb99fbea5d90106be0c6d5c505d293ab
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-10-04 03:12:50 +03:00
parent efa3c8557a
commit f780159afe
6 changed files with 31 additions and 6 deletions

View File

@@ -11,9 +11,19 @@ func main() {
app.Get("/", info)
// GET: http://localhost:8080/profile/anyusername
//
// Want to use a custom regex expression instead?
// Easy: app.Get("/profile/{username:string regexp(^[a-zA-Z ]+$)}")
app.Get("/profile/{username:string}", info)
// If parameter type is missing then it's string which accepts anything,
// i.e: /{paramname} it's exactly the same as /{paramname:string}.
// The below is exactly the same as
// {username:string}
//
// GET: http://localhost:8080/profile/anyusername/backups/any/number/of/paths/here
app.Get("/profile/{username:string}/backups/{filepath:path}", info)
app.Get("/profile/{username}/backups/{filepath:path}", info)
// Favicon
// GET: http://localhost:8080/favicon.ico