Exemple #1
0
func (b *BasicController) GetConfiguredRepository(pathVars map[string]string) *repository.EtcdBaseRepository {
	finalPath := b.basePath
	for key, value := range pathVars {
		finalPath = strings.Replace(finalPath, "{"+key+"}", value, 1)
	}
	repo := repository.NewEctdRepository()
	repo.SetCollection(finalPath)
	return repo
}
Exemple #2
0
func NewBasicController(basePath string, allowOrigin bool, defaultTTL int, setValidation func(map[string]interface{}, map[string]string) bool) (*BasicController, error) {
	var b = new(BasicController)
	b.allowOrigin = allowOrigin
	b.basePath = basePath
	b.defaultTTL = strconv.Itoa(defaultTTL)
	b.setValidation = setValidation
	var err error
	b.PathVariables, err = extractPathVariables(basePath)
	if err != nil {
		return nil, err
	}
	b.repo = repository.NewEctdRepository()
	return b, nil
}
Exemple #3
0
func validateInstance(app map[string]interface{}, vars map[string]string) bool {
	if len(app) == 1 {
		var repo *repository.EtcdBaseRepository = repository.NewEctdRepository()
		repo.SetCollection("/apps")
		_, err := repo.Get(vars["appId"])
		if err != nil {
			log.Warn(err)
			log.Warn("validateInstance: Error getting app " + vars["appId"])
			return false
		}
		return true
	} else {
		return false
	}
}