INNER CODE UNIT · Go

parseRoutes

docker/compose · relay/main.go:96

func parseRoutes(spec string) (map[int]string, error) {
	if strings.TrimSpace(spec) == "" {
		return nil, errors.New("no routes configured")
	}
	routes := map[int]string{}
	for _, entry := range strings.Split(spec, ",") {
		portPart, upstream, found := strings.Cut(entry, "=")
		if !found {
			return nil, fmt.Errorf("invalid route %q (want port=host:port)", entry)
		}
		port, err := strconv.Atoi(portPart)
		if err != nil || port < 1 || port > 65535 {
			return nil, fmt.Errorf("invalid port in route %q", entry)
		}
		host, hostPort, err := net.SplitHostPort(upstream)
		if err != nil {
			return nil, fmt.Errorf("invalid upstream in route %q: %w", entry, err)
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…