Documentation ¶
Index ¶
- Constants
- Variables
- func GetRealFormatTime(f string) string
- func GetSortQuery(sortBy, sort string) bson.M
- func NewPaginatedResponse(q pagination.Query, d PaginatedData) (interface{}, error)
- func NewValidationErrorResponse(err error, request interface{}) interface{}
- func ValidateAlarmPatterns(sl validator.FieldLevel) bool
- func ValidateCpsTimeType(field reflect.Value) interface{}
- func ValidateFilteredQuery(sl validator.StructLevel)
- func ValidateID(fl validator.FieldLevel) bool
- func ValidateOneOfOrEmpty(fl validator.FieldLevel) bool
- func ValidateTimeFormat(fl validator.FieldLevel) bool
- type BulkCrudAPI
- type CrudAPI
- type ErrorResponse
- type FieldValidator
- type PaginatedData
- type PaginatedListResponse
- type PaginatedMeta
- type ValidationErrorResponse
Constants ¶
View Source
const ( SortAsc = "asc" SortDesc = "desc" MaxIDLength = 255 )
Variables ¶
View Source
var ErrTimeoutResponse = ErrorResponse{Error: "Request timeout reached"}
View Source
var ForbiddenResponse = ErrorResponse{Error: "Forbidden"}
View Source
var InternalServerErrorResponse = ErrorResponse{Error: "Internal server error"}
View Source
var NotFoundResponse = ErrorResponse{Error: "Not found"}
Functions ¶
func GetRealFormatTime ¶
func GetSortQuery ¶
func NewPaginatedResponse ¶
func NewPaginatedResponse(q pagination.Query, d PaginatedData) (interface{}, error)
func NewValidationErrorResponse ¶
func NewValidationErrorResponse(err error, request interface{}) interface{}
NewValidationErrorResponse creates response by validation errors.
func ValidateAlarmPatterns ¶
func ValidateAlarmPatterns(sl validator.FieldLevel) bool
func ValidateCpsTimeType ¶
ValidateCpsTimeType implements CustomTypeFunc and returns value to validate.
func ValidateFilteredQuery ¶
func ValidateFilteredQuery(sl validator.StructLevel)
func ValidateID ¶
func ValidateID(fl validator.FieldLevel) bool
func ValidateOneOfOrEmpty ¶
func ValidateOneOfOrEmpty(fl validator.FieldLevel) bool
func ValidateTimeFormat ¶
func ValidateTimeFormat(fl validator.FieldLevel) bool
Types ¶
type BulkCrudAPI ¶
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse is base failed response.
func NewErrorResponse ¶
func NewErrorResponse(err error) ErrorResponse
type FieldValidator ¶
func NewExistFieldValidator ¶
func NewExistFieldValidator( db mongo.DbClient, collection string, field string, ) FieldValidator
func NewUniqueBulkFieldValidator ¶
func NewUniqueBulkFieldValidator(field string) FieldValidator
func NewUniqueFieldValidator ¶
func NewUniqueFieldValidator( db mongo.DbClient, collection string, field string, ) FieldValidator
type PaginatedData ¶
type PaginatedData interface { GetData() interface{} GetTotal() int64 }
PaginatedData provides access to inner data and total count
type PaginatedListResponse ¶
type PaginatedListResponse struct { Data interface{} `json:"data"` Meta PaginatedMeta `json:"meta"` }
PaginatedListResponse is response for paginated list data.
type PaginatedMeta ¶
type PaginatedMeta struct { Page int64 `json:"page"` PerPage int64 `json:"per_page"` PageCount int64 `json:"page_count"` TotalCount int64 `json:"total_count"` }
PaginatedMeta is meta for paginated list data.
type ValidationErrorResponse ¶
ValidationErrorResponse is response for failed validation.
Click to show internal directories.
Click to hide internal directories.