Add initial site list resource
This commit is contained in:
parent
d55a7ec5af
commit
e894ae28dc
3 changed files with 72 additions and 0 deletions
34
resource/site.go
Normal file
34
resource/site.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package resource
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
//"github.com/aarondl/opt/null"
|
||||
//"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type siteR struct {
|
||||
router *router
|
||||
}
|
||||
|
||||
func Site(r *router) *siteR {
|
||||
return &siteR{
|
||||
router: r,
|
||||
}
|
||||
}
|
||||
|
||||
func (res *siteR) List(ctx context.Context, r *http.Request, user platform.User, query QueryParams) ([]*types.Site, *nhttp.ErrorWithStatus) {
|
||||
limit := 20
|
||||
if query.Limit != nil {
|
||||
limit = *query.Limit
|
||||
}
|
||||
sites, err := platform.SiteList(ctx, user, limit)
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("list signals: %w", err)
|
||||
}
|
||||
return sites, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue