gen-gin-handler

command module
v0.0.0-...-1dea177 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 11 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
example
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL