Skip to content

Request ​

the configuration of routes for user-related operations using the Echo web framework. The router is responsible for mapping incoming HTTP requests to their corresponding handler functions, allowing the application to process and respond to different types of requests.

Form Data ​

Form data can be retrieved by name usingContext#FormValue(name string).

go
// controller
func (m UserController) Create(c core.IHTTPContext) error {
  name := c.FormValue("name")
  return c.String(http.StatusOK, name)
}
bash
curl -X POST http://localhost:3000 -d 'name=Joe'

Query Parameters ​

Query parameters can be retrieved by name usingContext#QueryParam(name string).

go
// controller
func (m UserController) Create(c core.IHTTPContext) error {
  name := c.QueryParam("name")
  return c.String(http.StatusOK, name)
})
bash
curl\
  -X GET\
  http://localhost:3000\?name\=Joe

Similar to form data, custom data type can be bind usingContext#QueryParam(name string).

Path Parameters ​

Registered path parameters can be retrieved by name usingContext#Param(name string) string.

go
e.GET("/users/:name", core.WithHTTPContext(func(c core.IHTTPContext) error {
  name := c.Param("name")
  return c.String(http.StatusOK, name)
}))
bash
curl http://localhost:3000/users/Joe

Binding Data ​

Also binding of request data to native Go structs and variables is supported. See Binding Data

Maintained by Passakon Puttasuwan & Dev Core Team.