mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-07 09:49:41 +09:00
Add paging headers (#36521)
Adds support for paging in admin/hooks api endpoint fixes: https://github.com/go-gitea/gitea/issues/36516 --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: techknowlogick <matti@mdranta.net>
This commit is contained in:
@@ -57,8 +57,13 @@ func ListHooks(ctx *context.APIContext) {
|
||||
case "all":
|
||||
isSystemWebhook = optional.None[bool]()
|
||||
}
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
opts := &webhook.ListSystemWebhookOptions{
|
||||
ListOptions: listOptions,
|
||||
IsSystem: isSystemWebhook,
|
||||
}
|
||||
|
||||
sysHooks, err := webhook.GetSystemOrDefaultWebhooks(ctx, isSystemWebhook)
|
||||
sysHooks, total, err := webhook.GetGlobalWebhooks(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.APIErrorInternal(err)
|
||||
return
|
||||
@@ -72,6 +77,8 @@ func ListHooks(ctx *context.APIContext) {
|
||||
}
|
||||
hooks[i] = h
|
||||
}
|
||||
ctx.SetLinkHeader(int(total), listOptions.PageSize)
|
||||
ctx.SetTotalCountHeader(total)
|
||||
ctx.JSON(http.StatusOK, hooks)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user