Пример #1
0
func addRewrites(def string, cfg *lib.Config) (err error) {
	if def == "" {
		return
	}

	for _, definition := range strings.Split(def, ",") {
		err = cfg.AddRewriteRoute(definition)

		if err != nil {
			return
		}
	}

	return
}
Пример #2
0
func addMappings(def string, cfg *lib.Config) (err error) {
	if def == "" {
		return
	}

	for _, definition := range strings.Split(def, ",") {
		parts := strings.Split(definition, "=")

		if len(parts) != 2 {
			err = errors.New(fmt.Sprintf("syntax error in mapping: %s", def))
		} else {
			err = cfg.AddMapping(parts[0], parts[1])
		}

		if err != nil {
			return
		}
	}

	return
}