https://github.com/ganodermaking/easyrest
go easy rest
https://github.com/ganodermaking/easyrest
framework go restful web
Last synced: 3 months ago
JSON representation
go easy rest
- Host: GitHub
- URL: https://github.com/ganodermaking/easyrest
- Owner: ganodermaking
- License: mit
- Created: 2020-04-04T14:15:55.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-05T02:44:05.000Z (about 6 years ago)
- Last Synced: 2024-06-20T16:46:41.297Z (almost 2 years ago)
- Topics: framework, go, restful, web
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# easyrest
a easy restful framework
# install
```shell
go get -u github.com/ganodermaking/easyrest
```
# use
```go
func main() {
r := easyrest.New()
v1 := r.Group("/api/v1")
{
v1.GET("/users/:id([0-9]+)/:name([a-z]+)", func(c *easyrest.Context) {
c.JSON(http.StatusOK, easyrest.H{
"id": c.Query("id"),
"name": c.Query("name"),
})
})
v1.POST("/users/login", func(c *easyrest.Context) {
c.JSON(http.StatusOK, easyrest.H{
"username": c.PostForm("username"),
"password": c.PostForm("password"),
})
})
}
r.Run(":5000")
}
```