1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-24 23:24:00 +02:00

added ?fields query parameter support to limit the returned api fields

This commit is contained in:
Gani Georgiev
2023-04-25 17:58:51 +03:00
parent 841a4b6913
commit c0a7d0f6c0
5 changed files with 334 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import (
"github.com/labstack/echo/v5"
"github.com/labstack/echo/v5/middleware"
"github.com/pocketbase/pocketbase/core"
"github.com/pocketbase/pocketbase/tools/rest"
"github.com/pocketbase/pocketbase/ui"
"github.com/spf13/cast"
)
@@ -25,6 +26,9 @@ const trailedAdminPath = "/_/"
func InitApi(app core.App) (*echo.Echo, error) {
e := echo.New()
e.Debug = app.IsDebug()
e.JSONSerializer = &rest.Serializer{
FieldsParam: "fields",
}
// configure a custom router
e.ResetRouterCreator(func(ec *echo.Echo) echo.Router {