-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix issue gogf#2516 * golang ci configuration updates * add example for default value of http request
- Loading branch information
Showing
3 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gogf/gf/v2/frame/g" | ||
"github.com/gogf/gf/v2/net/ghttp" | ||
) | ||
|
||
type GetListReq struct { | ||
g.Meta `path:"/" method:"get"` | ||
Type string `v:"required#请选择内容模型" dc:"内容模型"` | ||
Page int `v:"min:0#分页号码错误" dc:"分页号码" d:"1"` | ||
Size int `v:"max:50#分页数量最大50条" dc:"分页数量,最大50" d:"10"` | ||
Sort int `v:"in:0,1,2#排序类型不合法" dc:"排序类型(0:最新, 默认。1:活跃, 2:热度)"` | ||
} | ||
type GetListRes struct { | ||
Items []Item `dc:"内容列表"` | ||
} | ||
|
||
type Item struct { | ||
Id int64 `dc:"内容ID"` | ||
Title string `dc:"内容标题"` | ||
} | ||
|
||
type Controller struct{} | ||
|
||
func (Controller) GetList(ctx context.Context, req *GetListReq) (res *GetListRes, err error) { | ||
g.Log().Info(ctx, req) | ||
return | ||
} | ||
|
||
func main() { | ||
s := g.Server() | ||
s.Group("/content", func(group *ghttp.RouterGroup) { | ||
group.Middleware(ghttp.MiddlewareHandlerResponse) | ||
group.Bind(&Controller{}) | ||
}) | ||
s.SetPort(8199) | ||
s.Run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters