ui/object.go
func (h *Handler) GetObject(
	tkn, objectType, id string) (json.RawMessage, error) {
	logger := h.logger.Add("method", "GetObject",
		"type", objectType, "id", id)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	table, ok := objectTypes[objectType]
	if !ok {
		logger.Warn(ErrBadObjectType.Error())
		return nil, ErrBadObjectType
	}

	obj, err := h.db.FindByPrimaryKeyFrom(table, id)
	if err != nil {
		logger.Error(err.Error())
		return nil, ErrObjectNotFound
	}

	raw, err := json.Marshal(obj)
	if err != nil {
		logger.Error(err.Error())
		return nil, ErrInternal
	}

	return raw, nil
}
func (h *Handler) GetObject(
	tkn, objectType, id string) (json.RawMessage, error) {
	logger := h.logger.Add("method", "GetObject",
		"type", objectType, "id", id)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	table, ok := objectTypes[objectType]
	if !ok {
		logger.Warn(ErrBadObjectType.Error())
		return nil, ErrBadObjectType
	}

	obj, err := h.db.FindByPrimaryKeyFrom(table, id)
	if err != nil {
		logger.Error(err.Error())
		return nil, ErrObjectNotFound
	}

	raw, err := json.Marshal(obj)
	if err != nil {
		logger.Error(err.Error())
		return nil, ErrInternal
	}

	return raw, nil
}
func ( h * Handler ) GetObject ( tkn , objectType , id string ) ( json . RawMessage , error ) { logger := h . logger . Add ( " " , " " , " " , objectType , " " , id ) if ! h . token . Check ( tkn ) { logger . Warn ( " " ) return nil , ErrAccessDenied } table , ok := objectTypes [ objectType ] if ! ok { logger . Warn ( ErrBadObjectType . Error ( ) ) return nil , ErrBadObjectType } obj , err := h . db . FindByPrimaryKeyFrom ( table , id ) if err != nil { logger . Error ( err . Error ( ) ) return nil , ErrObjectNotFound } raw , err := json . Marshal ( obj ) if err != nil { logger . Error ( err . Error ( ) ) return nil , ErrInternal } return raw , nil }
// GetObject finds object in a database by id,
// then returns an object on raw JSON format.
GetObject finds object in a database by id then returns an object on raw JSON format .