MCPcopy Create free account
hub / github.com/kataras/iris / List

Method List

_examples/database/mysql/api/category_handler.go:63–79  ·  view source on GitHub ↗

* type ( List struct { Data interface{} `json:"data"` Order string `json:"order"` Next Range `json:"next,omitempty"` Prev Range `json:"prev,omitempty"` } Range struct { Offset int64 `json:"offset"` Limit int64 `json:"limit` } ) */ List lists a set of records fr

(ctx iris.Context)

Source from the content-addressed store, hash-verified

61// List lists a set of records from the database.
62// Method: GET.
63func (h *CategoryHandler) List(ctx iris.Context) {
64 q := ctx.Request().URL.Query()
65 opts := sql.ParseListOptions(q)
66
67 // initialize here in order to return an empty json array `[]` instead of `null`.
68 categories := entity.Categories{}
69 err := h.service.List(ctx.Request().Context(), &categories, opts)
70 if err != nil && err != sql.ErrNoRows {
71 debugf("CategoryHandler.List(DB) (limit=%d offset=%d where=%s=%v): %v",
72 opts.Limit, opts.Offset, opts.WhereColumn, opts.WhereValue, err)
73
74 writeInternalServerError(ctx)
75 return
76 }
77
78 ctx.JSON(categories)
79}
80
81// Create adds a record to the database.
82// Method: POST.

Callers

nothing calls this directly

Calls 7

debugfFunction · 0.85
writeInternalServerErrorFunction · 0.85
RequestMethod · 0.80
ContextMethod · 0.80
QueryMethod · 0.65
ListMethod · 0.65
JSONMethod · 0.45

Tested by

no test coverage detected