$ go version
go version go1.15.14 linux/amd64
$ mkdir myapp && cd myapp
$ go mod init myapp
$ ls
go.mod
module myapp go 1.15
$ go get github.com/labstack/echo/v4
$ ls
go.mod go.sum
server.go
package main import ( "net/http" "github.com/labstack/echo/v4" ) func main() { e := echo.New() e.GET("/", func(c echo.Context) error{ return c.String(http.StatusOK, "Hello, Echo") }) e.Logger.Fatal(e.Start(":1323")) }
$ go run server.go
type User struct { Name string `json:"name"` Email string `json:"email"` } func main() { e := echo.New() e.GET("/", func(c echo.Context) error{ return c.String(http.StatusOK, "Hello, Echo") }) e.GET("/user", show) e.Logger.Fatal(e.Start(":1323")) } func show(c echo.Context) error { u := new(User) if err := c.Bind(u); err != nil { return err } return c.JSON(http.StatusOK, u) }
http://192.168.33.10:1323/user?name=hpscript&email=info@hpscript.com
ん? なんかオカシイ