1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-26 20:54:00 +02:00
echo/example/main.go

42 lines
545 B
Go
Raw Normal View History

package main
import (
"net/http"
"github.com/labstack/bolt"
)
type user struct {
Id string
Name string
}
var users map[string]*user
func init() {
users = map[string]*user{
"1": &user{
Id: "1",
Name: "Wreck-It Ralph",
},
}
}
func createUser(c *bolt.Context) {
}
func getUsers(c *bolt.Context) {
c.RenderJSON(http.StatusOK, users)
}
func getUser(c *bolt.Context) {
c.RenderJSON(http.StatusOK, users[c.P(0)])
}
func main() {
b := bolt.New()
b.Get("/users", getUsers)
b.Get("/users/:id", getUser)
b.Run(":8080")
}