Example #1
0
func newFilesystemEndpoint(path string, notfound []string) (*filesystemEndpoint, error) {
	rparts := []routespec.RouteSpec{}
	for _, p := range notfound {
		rp, err := routespec.ParseRouteSpec(p)
		if err != nil {
			return nil, err
		}
		if rp.IsURL {
			return nil, fmt.Errorf("Not found over-ride target cannot be a URL.")
		}
		rparts = append(rparts, *rp)
	}
	return &filesystemEndpoint{path, rparts}, nil
}
Example #2
0
// Constructs a new route from a string specifcation. Specifcations are of the
// form ANCHOR=VALUE.
func newRoute(s string, notfound []string) (*Route, error) {
	rp, err := routespec.ParseRouteSpec(s)
	if err != nil {
		return nil, err
	}

	var ep endpoint

	if rp.IsURL {
		ep, err = newForwardEndpoint(rp.Value)
	} else {
		ep, err = newFilesystemEndpoint(rp.Value, notfound)
	}
	if err != nil {
		return nil, err
	}
	return &Route{rp.Host, rp.Path, ep}, nil
}