Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ block_test.out
heap_test.out
cpu_test.txt
cover_profile_test.txt
build.bat
build.bat

_examples/*.o
_examples/*.a
_examples/*.so
24 changes: 23 additions & 1 deletion _examples/named_parameters/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
package main

import "github.com/kataras/iris"
import (
"strconv"

"github.com/kataras/iris"
)

func main() {

// Match to /hello/iris
// Not match to /hello or /hello/ or /hello/iris/something
iris.Get("/hello/:name", func(c *iris.Context) {
// Retrieve the parameter name
name := c.Param("name")
c.Write("Hello " + name)
})

// Match to /profile/iris/friends/1
// Not match to /profile/ , /profile/iris ,
// Not match to /profile/iris/friends, /profile/iris/friends ,
// Not match to /profile/iris/friends/2/something
iris.Get("/profile/:fullname/friends/:friendID", func(c *iris.Context) {
// Retrieve the parameters fullname and friendID
fullname := c.Param("fullname")
friendID, err := c.ParamInt("friendID")
if err != nil {
// Do something with the error
}
c.HTML("<b> Hello </b>" + fullname + "<b> with friends ID </b>" + strconv.Itoa(friendID))
})

// Listen to port 8080 for example localhost:8080
iris.Listen(8080)
}