# README
angle
angle is a Go framework with battery included.
Highlight Features
Getting Started
Install angle:
go get github.com/go-angle/angle
Create config.yml
:
name: minimal
stage: development
Then here is the code:
package main
import (
"github.com/go-angle/angle"
"github.com/go-angle/angle/log"
)
func main() {
ch, _, err := angle.Start("config.yml")
if err != nil {
log.Fatalf("bootstrap failed with error: %v", err)
}
<-ch
angle.Stop()
}
Now we can run it:
go run main.go
Automatically Binding
package main
import (
"errors"
"github.com/gin-gonic/gin"
"github.com/go-angle/angle"
"github.com/go-angle/angle/di"
"github.com/go-angle/angle/gh"
"github.com/go-angle/angle/log"
"go.uber.org/fx"
)
func main() {
ch, _, err := angle.Start("config.yml")
if err != nil {
log.Fatalf("bootstrap failed with error: %v", err)
}
<-ch
angle.Stop()
}
type routerParams struct {
fx.In
Default *gin.RouterGroup `name:"api"`
}
func init() {
gh.ProvideRouterGroup("api", func(app *gh.App) *gin.RouterGroup {
return app.Engine.Group("api")
})
di.Invoke(func(r routerParams) {
r.Default.POST("/users", gh.MustBind(createUser).HandlerFunc())
})
}
type UserReq struct {
Name string `json:"name"`
Age int `json:"age"`
}
type UserResponse struct {
Ok bool `json:"ok"`
ID int `json:"id"`
}
func createUser(req *UserReq) (*UserResponse, error) {
if req.Age <= 0 {
return nil, errors.New("no, it's impossiable")
}
return &UserResponse{
Ok: true,
ID: 1,
}, nil
}
More
More details please see examples.
# Packages
No description provided by the author
No description provided by the author
Package di is a wrapper of fx, which allows to use DI across the whole lifecycle.
No description provided by the author
Package gh is an abbreviation of gin http.
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
Version of current.