mirror of
https://github.com/kataras/iris.git
synced 2026-01-08 04:21:57 +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:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user