-
-
Notifications
You must be signed in to change notification settings - Fork 178
/
main.go
41 lines (34 loc) · 904 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/mvc"
)
func main() {
app := iris.New()
usersRouter := app.Party("/users")
mvc.New(usersRouter).Handle(new(myController))
// Same as:
// usersRouter.Get("/{p:path}", func(ctx iris.Context) {
// wildcardPathParameter := ctx.Params().Get("p")
// ctx.JSON(response{
// Message: "The path parameter is: " + wildcardPathParameter,
// })
// })
/*
curl --location --request GET 'http://localhost:8080/users/path_segment_1/path_segment_2'
Expected Output:
{
"message": "The wildcard is: path_segment_1/path_segment_2"
}
*/
app.Listen(":8080")
}
type myController struct{}
type response struct {
Message string `json:"message"`
}
func (c *myController) GetByWildcard(wildcardPathParameter string) response {
return response{
Message: "The path parameter is: " + wildcardPathParameter,
}
}