GoGym
is a framework for building RESTful APIs, which is written in Golang
. It is inspired by an artisan framework Laravel.
Icon made by @Beth Wardolf
-
Dependencies:
$ go get github.com/sirupsen/logrus
-
Install the package from the command line:
$ 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: Receive request and send JSON response. [Finished]
- v0.2: Support route parameters. [In development]
- v0.3: Support using functions directly when defining routes.
- v0.4: Support middleware.
Your contribution to GoGym
development is very welcomed!
You may contribute in the following ways:
- Post issues and feedbacks.
- Submit fixes, features via the Pull Request.
- Write/polish the documentation. The documentation exists in folder
doc
.
Thanks for all contributors.
GoGym
is released under the MIT License.