mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-26 13:48:53 +08:00

* MF-1061 - Add PageMetadata to readers Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix merge conflicts Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Mv Total to MessagesPage Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix review Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix readers mock and add filters tests Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add Total check and allow combinations of query parameters Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use slices length as Total Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Simplify readers mock Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Add empty lines Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
36 lines
605 B
Go
36 lines
605 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/mainflux/mainflux"
|
|
"github.com/mainflux/mainflux/readers"
|
|
)
|
|
|
|
var _ mainflux.Response = (*pageRes)(nil)
|
|
|
|
type pageRes struct {
|
|
readers.PageMetadata
|
|
Total uint64 `json:"total"`
|
|
Messages []readers.Message `json:"messages,omitempty"`
|
|
}
|
|
|
|
func (res pageRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res pageRes) Code() int {
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res pageRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
type errorRes struct {
|
|
Err string `json:"error"`
|
|
}
|