Categorygithub.com/eatmoreapple/ginx
repositorypackage
0.0.0-20241022032238-46bae23fd750
Repository: https://github.com/eatmoreapple/ginx.git
Documentation: pkg.go.dev

# README

ginx

Example

package main

import (
	"context"
	"github.com/eatmoreapple/ginx"
	"github.com/gin-gonic/gin"
)

type User struct {
	Name string `json:"name" form:"name"`
}

func helloworld(_ context.Context, req User) (any, error) {
	if req.Name == "" {
		req.Name = "hello world"
	}
	return req, nil
}

func main() {
	engine := gin.Default()
	router := ginx.NewRouter(engine)
	router.GET("/", ginx.G(helloworld).JSON())
	engine.Run(":8080")
}