优化响应中间件,自动识别响应数据格式

This commit is contained in:
孟帅
2023-06-16 19:58:29 +08:00
parent 50e64e132f
commit 9b89402bf6
13 changed files with 112 additions and 128 deletions

View File

@@ -7,8 +7,9 @@ package user
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"fmt"
"hotgo/api/api/user"
"hotgo/utility/simple"
)
var (
@@ -17,7 +18,9 @@ var (
type cHello struct{}
func (c *cHello) Hello(ctx context.Context, _ *user.HelloReq) (res *user.HelloRes, err error) {
g.RequestFromCtx(ctx).Response.Writeln("Hello World api member!")
func (c *cHello) Hello(ctx context.Context, req *user.HelloReq) (res *user.HelloRes, err error) {
res = &user.HelloRes{
Tips: fmt.Sprintf("hello %v, this is the api for %v applications.", req.Name, simple.AppName(ctx)),
}
return
}