query string
?name=wook
query string 으로 전달되는 파라미터 획득
1 2 3 4 5
| func(c echo.Context) error { name := c.QueryParam("name") return c.String(http.StatusOK, name) })
|
path variable
/users/:name
uri 의 path variable 획득
1 2 3 4 5
| e.GET("/users/:name", func(c echo.Context) error { name := c.Param("name") return c.String(http.StatusOK, name) })
|
Content-Type: multipart/form-data
Content-Type: x-www-form-urlencoded
form submit을 통해 전달되는 파라미터 획득
1 2 3 4 5
| func(c echo.Context) error { name := c.FormValue("name") return c.String(http.StatusOK, name) }
|
JSON body
Content-Type: application/json
body 에 포함된 json 데이터 획득
1 2 3 4 5 6
| func (c echo.Context) error { params := make(map[string]string) _ := c.Bind(¶ms) return c.JSON(http.StatusOK, params["name"]) }
|