mirror of
https://gitee.com/johng/gf
synced 2026-06-14 04:55:42 +08:00
add # for cron pattern that can ignore seconds, which makes the cron pattern running in minimum minute like linux crontab pattern (#3306)
This commit is contained in:
40
example/httpserver/response-with-json-array/controller.go
Normal file
40
example/httpserver/response-with-json-array/controller.go
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type Req struct {
|
||||
g.Meta `path:"/user" method:"get"`
|
||||
}
|
||||
|
||||
type Res []Item
|
||||
|
||||
type Item struct {
|
||||
Id int64
|
||||
Name string
|
||||
}
|
||||
|
||||
var (
|
||||
User = cUser{}
|
||||
)
|
||||
|
||||
type cUser struct{}
|
||||
|
||||
func (c *cUser) GetList(ctx context.Context, req *Req) (res *Res, err error) {
|
||||
res = &Res{
|
||||
{Id: 1, Name: "john"},
|
||||
{Id: 2, Name: "smith"},
|
||||
{Id: 3, Name: "alice"},
|
||||
{Id: 4, Name: "katyusha"},
|
||||
}
|
||||
return
|
||||
}
|
||||
29
example/httpserver/response-with-json-array/main.go
Normal file
29
example/httpserver/response-with-json-array/main.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||
group.Middleware(ghttp.MiddlewareHandlerResponse)
|
||||
group.Bind(
|
||||
User,
|
||||
)
|
||||
})
|
||||
oai := s.GetOpenApi()
|
||||
oai.Config.CommonResponse = ghttp.DefaultHandlerResponse{}
|
||||
oai.Config.CommonResponseDataField = "Data"
|
||||
s.SetOpenApiPath("/api")
|
||||
s.SetSwaggerPath("/swagger")
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
Reference in New Issue
Block a user