32 lines
837 B
Go
32 lines
837 B
Go
package hello
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
|
"remote-msg/api/hello/v1"
|
|
)
|
|
|
|
func (c *ControllerV1) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) {
|
|
g.RequestFromCtx(ctx).Response.Writeln("Hello World!")
|
|
return
|
|
}
|
|
|
|
func (c *ControllerV1) Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) {
|
|
//获取get请求参数
|
|
param := g.RequestFromCtx(ctx).URL.Query()
|
|
fmt.Println(gconv.String(param))
|
|
g.RequestFromCtx(ctx).Response.Writeln("get success!")
|
|
return
|
|
}
|
|
|
|
func (c *ControllerV1) Post(ctx context.Context, req *v1.PostReq) (res *v1.PostRes, err error) {
|
|
//获取post请求参数
|
|
body := g.RequestFromCtx(ctx).GetBody()
|
|
fmt.Println(gconv.String(body))
|
|
g.RequestFromCtx(ctx).Response.Writeln("post success!")
|
|
return
|
|
}
|