mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-01 13:48:56 +08:00

* Add pagination response to the readers Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com> * Remove println from influx reader Signed-off-by: Aleksandar Novakovic <aleksandar.novakovic@mainflux.com>
35 lines
653 B
Go
35 lines
653 B
Go
//
|
|
// Copyright (c) 2018
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package api
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-kit/kit/endpoint"
|
|
"github.com/mainflux/mainflux/readers"
|
|
)
|
|
|
|
func listMessagesEndpoint(svc readers.MessageRepository) endpoint.Endpoint {
|
|
return func(_ context.Context, request interface{}) (interface{}, error) {
|
|
req := request.(listMessagesReq)
|
|
|
|
if err := req.validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
page := svc.ReadAll(req.chanID, req.offset, req.limit, req.query)
|
|
|
|
return pageRes{
|
|
Total: page.Total,
|
|
Offset: page.Offset,
|
|
Limit: page.Limit,
|
|
Messages: page.Messages,
|
|
}, nil
|
|
}
|
|
}
|