// SSE is a method for actions.SSE func (action *PaymentsIndexAction) SSE(stream sse.Stream) { action.Setup(action.LoadQuery) action.Do( action.LoadRecords, func() { stream.SetLimit(int(action.Query.Limit)) records := action.Records[stream.SentCount():] for _, record := range records { res, err := resource.NewOperation(action.Ctx, record) if err != nil { stream.Err(action.Err) return } stream.Send(sse.Event{ ID: res.PagingToken(), Data: res, }) } }) }
// LoadPage populates action.Page func (action *PaymentsIndexAction) LoadPage() { for _, record := range action.Records { var res hal.Pageable res, action.Err = resource.NewOperation(action.Ctx, record) if action.Err != nil { return } action.Page.Add(res) } action.Page.BaseURL = action.BaseURL() action.Page.BasePath = action.Path() action.Page.Limit = action.Query.Limit action.Page.Cursor = action.Query.Cursor action.Page.Order = action.Query.Order action.Page.PopulateLinks() }
func (action *OperationShowAction) LoadResource() { action.Resource, action.Err = resource.NewOperation(action.Ctx, action.Record) }