diff --git a/README.md b/README.md index f5f75d23..5ffc6ae5 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Help this project to continue deliver awesome and unique features with the highe ### 🚀 Installation -The only requirement is the [Go Programming Language](https://golang.org/dl/), at least version 1.8 but **1.9** is highly recommended. +The only requirement is the [Go Programming Language](https://golang.org/dl/), at least version 1.9. ```sh $ go get -u github.com/kataras/iris @@ -158,6 +158,13 @@ func main() { // Method: GET // Resource: http://localhost:8080/user/42 + // + // Need to use a custom regexp instead? + // Easy; + // Just mark the parameter's type to 'string' + // which accepts anything and make use of + // its `regexp` macro function, i.e: + // app.Get("/user/{id:string regexp(^[0-9]+$)}") app.Get("/user/{id:long}", func(ctx iris.Context) { userID, _ := ctx.Params().GetInt64("id") ctx.Writef("User ID: %d", userID) @@ -168,6 +175,8 @@ func main() { } ``` +> See all available path parameter types at: https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/main.go#L31 + ```html diff --git a/_examples/routing/overview/main.go b/_examples/routing/overview/main.go index dbf52938..65c15dc6 100644 --- a/_examples/routing/overview/main.go +++ b/_examples/routing/overview/main.go @@ -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 diff --git a/_examples/tutorial/dropzonejs/README.md b/_examples/tutorial/dropzonejs/README.md index fcf3e2fe..ab99edfd 100644 --- a/_examples/tutorial/dropzonejs/README.md +++ b/_examples/tutorial/dropzonejs/README.md @@ -152,7 +152,7 @@ func main() { 7. If file is sent to the page, store the file object to a temporary "file" variable. 8. Move uploaded file to destination based on the uploadsDir+uploaded file's name. -### Runing the server +### Running the server Open the terminal at the current project's folder and execute: diff --git a/_examples/tutorial/dropzonejs/README_PART2.md b/_examples/tutorial/dropzonejs/README_PART2.md index c490fb3d..24da5fef 100644 --- a/_examples/tutorial/dropzonejs/README_PART2.md +++ b/_examples/tutorial/dropzonejs/README_PART2.md @@ -98,7 +98,7 @@ func (f *uploadedFiles) scan(dir string) { f.dir = dir filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { - // if it's directory or a thumbnail we saved ealier, skip it. + // if it's directory or a thumbnail we saved earlier, skip it. if info.IsDir() || strings.HasPrefix(info.Name(), "thumbnail_") { return nil } @@ -283,7 +283,7 @@ Copy content below to "./views/upload.html". We will go through modifications in 4. Retrieve files details from the new "/uploads" via ajax. 5. Create mockFile using values from server. mockFile is simply JavaScript objects with properties of name and size. Then we call Dropzone's **addedfile** and **thumbnail** functions explicitly to put existing files to Dropzone upload area and generate its thumbnail. -### Runing the server +### Running the server Open the terminal at the current project's folder and execute: diff --git a/_examples/tutorial/dropzonejs/src/main.go b/_examples/tutorial/dropzonejs/src/main.go index c49f0c72..c5522808 100644 --- a/_examples/tutorial/dropzonejs/src/main.go +++ b/_examples/tutorial/dropzonejs/src/main.go @@ -55,7 +55,7 @@ func (f *uploadedFiles) scan(dir string) { f.dir = dir filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { - // if it's directory or a thumbnail we saved ealier, skip it. + // if it's directory or a thumbnail we saved earlier, skip it. if info.IsDir() || strings.HasPrefix(info.Name(), "thumbnail_") { return nil } diff --git a/doc.go b/doc.go index cb250cca..caeba077 100644 --- a/doc.go +++ b/doc.go @@ -110,6 +110,12 @@ Example code: // Method GET: http://localhost:8080/profile/anytypeofstring app.Get("/profile/{username:string}", profileByUsername) + // Want to use a custom regex expression instead? + // Easy: app.Get("/profile/{username:string regexp(^[a-zA-Z ]+$)}") + // + // If parameter type is missing then it's string which accepts anything, + // i.e: /{paramname} it's exactly the same as /{paramname:string}. + usersRoutes := app.Party("/users", logThisMiddleware) { // Method GET: http://localhost:8080/users/42