GoGym
是一个用Golang构建的RESTful APIs的框架。它深受Laravel启发,希望能帮助用户优雅快速地构建API服务。
-
项目依赖:
$ go get github.com/sirupsen/logrus
-
通过命令行输入
$ go get github.com/ZhenhangTung/GoGym
type HelloController struct {
}
func (h *HelloController) SayHello(api *GoGym.Gym) {
// Your logic goes there
}
var gym = new(GoGym.Gym)
gym.Prepare()
gym.Router.RegisterController(&HelloController{})
gym.Router.Get("/", "HelloController@SayHello")
gym.OpenAt(3000)
package main
import (
"github.com/ZhenhangTung/GoGym"
"net/http"
)
type HelloController struct {
}
func (h *HelloController) SayHello(api *GoGym.Gym) {
api.Response.JsonResponse(map[string]string{"msg": "Hello World!"}, 200, http.Header{})
}
func main() {
var gym = new(GoGym.Gym)
gym.Prepare()
gym.Router.RegisterController(&HelloController{})
gym.Router.Get("/", "HelloController@SayHello")
gym.OpenAt(3000)
}
// Then open the http://localhost:3000 to see the result
- v0.1: 接收请求,返回JSON响应 [Finished]
- v0.2: 支持路由变量 [In development]
- v0.3: 支持定义路由时候直接传入function
- v0.4: 支持中间件
十分欢迎参与GoGym
的开发
你可以通过如下的方式参与:
- 发布issue或者feedback。
- 通过Pull Request来提交bug fix或者new feature。
- 写文档或者修饰文档,文档在项目文件夹
doc
下面。
感谢所有的贡献成员
GoGym
遵守MIT License.