Gen-Gin-Handler
Gen-Gin-Handler is gin handler generator
Quick Start
Install gen-gin-handler
go get github.com/15ho/gen-gin-handler
Declare apis
package api
import (
"github.com/15ho/gen-gin-handler/example/models"
"os"
)
//go:generate gen-gin-handler
type userInfo struct {
UploadAvatar func(userId string, avatar *os.File) error `method:"post-form" route:"/upload_avatar"`
AddProfile func(userId string, profile *models.Profile) error `method:"post-json" route:"/add_profile"`
Profile func(userId string) (*models.Profile, error) `method:"post-json" route:"/profile"`
UserStatistics func() (userTotalCount, userDailyCount uint64, err error) `method:"get" route:"/user_statistics"`
}
type userAuth struct {
Register func(username, password string) (token string, err error) `method:"post-json" route:"/register"`
Login func(username, password string) (token string, err error) `method:"post-json" route:"/login"`
}
Generate gin handler
go generate example/api/api.go
or IDE(goland,vscode...) support double click //go:generate gen-gin-handler
execute
more on example