This is where RESTful routes are mapped by Klein
6616
private function addRoutesForModels()
    {
        foreach ($this->_models as $model) {
            $modelName = strtolower($model);
            $mainUrl = '/' . $modelName;
            $resourceUrl = '/' . $modelName . '/' . '[:id]';
            $controllerName = $model . 'Controller';

            $controller = new $controllerName();

            if ($model::$get_all_enabled) {
                $this->_router->respond('get', $mainUrl, function ($request) use ($controller) {
                    $controller->getAll();
                });
            }

            if ($model::$get_enabled) {
                $this->_router->respond('get', $resourceUrl, function ($request) use ($controller) {
                    $controller->get($request->id);
                });
            }

            if ($model::$create_enabled) {
                $this->_router->respond('post', $mainUrl, function ($request) use ($controller) {
                    $postParams = json_decode(file_get_contents('php://input'));
                    $controller->create($postParams);
                });
            }

            if ($model::$delete_enabled) {
                $this->_router->respond('delete', $resourceUrl, function ($request) use ($controller) {
                    $controller->delete($request->id);
                });
            }

            if ($model::$update_enabled) {
                $this->_router->respond('put', $resourceUrl, function ($request) use ($controller) {
                    $postParams = json_decode(file_get_contents('php://input'));
                    $controller->update($request->id, $postParams);
                });
            }
        }
    }
309925
protected Map<String, ZuulRoute> locateRoutes() {
		LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<>();
		for (ZuulRoute route : this.properties.getRoutes().values()) {
			routesMap.put(route.getPath(), route);
		}
		return routesMap;
	}
453415
function (params, route) {
                // Due to how our routing accepts arbitrary length folders 
                // The key param could be split between params.key and params.'0'
                // Return the combined keys
                var restOfKey = params['0'] || '';

                var key = params.key + restOfKey;

                // Check if this route ends with a / ensure the key also does (similar to strict routing)
                if (route.path.slice(-1) === '/' && key.slice(-1) !== '/') {
                    key = key + '/';
                }

                return key;
            }
127416
def handle_json_GET_routes(self, params):
    """"""
    schedule = self.server.schedule
    result = []
    for r in schedule.GetRouteList():
      result.append( (r.route_id, r.route_short_name, r.route_long_name) )
    result.sort(key = lambda x: x[1:3])
    return result
1241684
def route(verb, path, options = {}, &block)
      no_swagger = options[:no_swagger]
      options.delete(:no_swagger)
      if (verb == 'HEAD') || no_swagger
        super(verb, path, options, &block)
      else
        request_processor = create_request_processor(verb.downcase, path, options)
        super(verb, path, options) do |*params|
          response = catch(:halt) do
            request_processor.run(self, params, &block)
          end
          if settings.result_validation
            begin
              # Inspired from Sinatra#invoke
              if (Fixnum === response) or (String === response)
                response = [response]
              end
              if (Array === response) and (Fixnum === response.first)
                response_for_validation = response.dup
                response_status = response_for_validation.shift
                response_body = response_for_validation.pop
                response_headers = (response_for_validation.pop || {}).merge(self.response.header)
                response_content_type = response_headers['Content-Type']
                request_processor.validate_response(response_body, response_content_type, response_status)
              elsif response.respond_to? :each
                request_processor.validate_response(response.first.dup, self.response.header['Content-Type'], 200)
              end
            rescue Sinatra::SwaggerExposer::SwaggerInvalidException => e
              content_type :json
              throw :halt, [400, {:code => 400, :message => e.message}.to_json]
            end
          end
          throw :halt, response
        end
      end
    end
1195442
public static void mapping() {
        for (final Router router : routers) {
            final ContextHandlerMeta contextHandlerMeta = router.toContextHandlerMeta();
            RouteHandler.addContextHandlerMeta(contextHandlerMeta);
        }
    }
1226447
def declare_api_routes(config):
    """"""
    # The pregenerator makes sure we can generate a path using
    # request.route_path even if we don't have all the variables.
    #
    # For example, instead of having to do this:
    #     request.route_path('resource', hash=hash, ignore='')
    # it's possible to do this:
    #     request.route_path('resource', hash=hash)
    def pregenerator(path):
        # find all the variables in the path
        variables = [(s.split(':')[0], '') for s in path.split('{')[1:]]

        def wrapper(request, elements, kwargs):
            modified_kwargs = dict(variables)
            modified_kwargs.update(kwargs)
            return elements, modified_kwargs
        return wrapper

    def add_route(name, path, *args, **kwargs):
        return config.add_route(name, path, *args,
                                pregenerator=pregenerator(path), **kwargs)

    add_route('content', '/contents/{ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)}{separator:(:?)}{page_ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)?}{ignore:(/[^/.]*?/?)?}{ext:([.](html|json))?}')  # noqa cnxarchive.views:get_content
    add_route('resource', '/resources/{hash}{ignore:(/.*)?}')  # noqa cnxarchive.views:get_resource
    add_route('export', '/exports/{ident_hash}.{type}{ignore:(/.*)?}')  # noqa cnxarchive.views:get_export
    add_route('extras', '/extras{key:(/(featured|messages|licenses|subjects|languages))?}')  # noqa cnxarchive.views:extras
    add_route('content-extras', '/extras/{ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)}{separator:(:?)}{page_ident_hash:([^:/@.]+(@[0-9.]*[0-9]+)?)?}')  # noqa cnxarchive.views:get_extra
    add_route('search', '/search')  # cnxarchive.views:search
    add_route('in-book-search', '/search/{ident_hash:([^:/]+)}')  # noqa cnxarchive.views:in-book-search
    add_route('in-book-search-page', '/search/{ident_hash:([^:/]+)}:{page_ident_hash}')  # noqa cnxarchive.views:in_book_search_highlighted_results
    add_route('sitemap-index', '/sitemap_index.xml')  # noqa cnxarchive.views:sitemap
    add_route('sitemap', '/sitemap-{from_id}.xml')  # noqa cnxarchive.views:sitemap
    add_route('robots', '/robots.txt')  # noqa cnxarchive.views:robots
    add_route('legacy-redirect', '/content/{objid}{ignore:(/)?}')  # noqa cnxarchive.views:redirect_legacy_content
    add_route('legacy-redirect-latest', '/content/{objid}/latest{ignore:(/)?}{filename:(.+)?}')  # noqa cnxarchive.views:redirect_legacy_content
    add_route('legacy-redirect-w-version', '/content/{objid}/{objver}{ignore:(/)?}{filename:(.+)?}')  # noqa cnxarchive.views:redirect_legacy_content
    add_route('recent', '/feeds/recent.rss')  # cnxarchive.views:recent
    add_route('oai', '/feeds/oai')  # cnxarchive.views:oai
    add_route('xpath', '/xpath.html')  # cnxarchive.views.xpath
    add_route('xpath-json', '/xpath.json')
941574
function routeIsActive(pathname, routes, params, indexOnly) {
  // TODO: This is a bit ugly. It keeps around support for treating pathnames
  // without preceding slashes as absolute paths, but possibly also works
  // around the same quirks with basenames as in matchRoutes.
  if (pathname.charAt(0) !== '/') {
    pathname = `/${pathname}`
  }

  const i = getMatchingRouteIndex(pathname, routes, params)

  if (i === null) {
    // No match.
    return false
  } else if (!indexOnly) {
    // Any match is good enough.
    return true
  }

  // If any remaining routes past the match index have paths, then we can't
  // be on the index route.
  return routes.slice(i + 1).every(route => !route.path)
}
767012
protected function mapWebRoutes()
    {
        Route::group([
            'middleware' => config($this->package.'.web_routes_middleware') ?: 'web',
            'namespace'  => $this->namespace,
            'prefix' => $this->prefix,
        ], function ($router) {
            require __DIR__.'/../Routes/web.php';
        });
    }
38510
function routerStrategy(metadata, dataAdapter, opts) {
    const { router, routePrefix } = opts;
    for (const name in metadata) {
        const obj = metadata[name];
        const { routeSwitch = {} } = obj;
        let originalPath = name.toLowerCase();
        if (routePrefix) {
            routePrefix = routePrefix.startsWith('/') ? routePrefix : `/${routePrefix}`;
            originalPath = `${routePrefix}/${originalPath}`;
        } else {
            originalPath = `/${originalPath}`;
        }
        for (const key in routes) {
            if (routeSwitch[key] !== true) continue;

            let path = originalPath;
            const route = routes[key];
            const { pres, posts } = getHooks(obj, key, opts);
            const middleware = route.call(null, name, dataAdapter, opts, pres, posts);

            let method = null;
            switch (key) {
                case 'list':
                    method = 'get';
                    break;
                case 'id':
                    path = `${path}/id`;
                    method = 'get';
                    break;
                case 'create':
                    method = 'post';
                    break;
                case 'update':
                    method = 'put';
                    break;
                case 'remove':
                    method = 'delete';
                    break;
            }

            if (!method) {
                continue;
            }

            router[method](path, middleware);
            if (typeof opts.onRoute === 'function') {
                opts.onRoute.call(null, { name, path, method, middleware, pres, posts });
            }
        }
    }
    return async function empty(ctx, next) {
        try {
            await next();
        } catch (err) {
            throw err;
        }
    };
}
898736
function routeSerializer(route) {
	if (route && route.path) {
		return {
			path: route.path,
			methods: route.methods,
			method: route.method
		};
	}
	return route;
}
584178
def define_resources_routes
      resources = namespaces.flat_map { |n| n.resources.values }
      resources.each do |config|
        define_resource_routes(config)
      end
    end
541323
def route
      # Sanitize the URI:
      # * Unescape escaped characters
      # * Replace runs of / with a single /
      path_info = Rack::Utils.unescape(request.path_info).gsub(%r{/+}, '/')

      ROUTES.each do |path_matcher, verb, handler|
        path_info.match(path_matcher) do |match|
          @repository_uri = match[1]
          @request_verb = verb

          return method_not_allowed unless verb == request.request_method
          return bad_request if bad_uri?(@repository_uri)

          git.repository_path = root + @repository_uri
          return not_found unless git.exist?

          return send(handler, *match[2..-1])
        end
      end
      not_found
    end
399306
static function createRequestUri($servicePath, $restPath, $params) {
    $requestUrl = $servicePath . $restPath;
    $uriTemplateVars = array();
    $queryVars = array();
    foreach ($params as $paramName => $paramSpec) {
      // Discovery v1.0 puts the canonical location under the 'location' field.
      if (! isset($paramSpec['location'])) {
        $paramSpec['location'] = $paramSpec['restParameterType'];
      }

      if ($paramSpec['type'] == 'boolean') {
        $paramSpec['value'] = ($paramSpec['value']) ? 'true' : 'false';
      }
      if ($paramSpec['location'] == 'path') {
        $uriTemplateVars[$paramName] = $paramSpec['value'];
      } else {
        if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
          foreach ($paramSpec['value'] as $value) {
            $queryVars[] = $paramName . '=' . rawurlencode($value);
          }
        } else {
          $queryVars[] = $paramName . '=' . rawurlencode($paramSpec['value']);
        }
      }
    }

    if (count($uriTemplateVars)) {
      $uriTemplateParser = new URI_Template_Parser($requestUrl);
      $requestUrl = $uriTemplateParser->expand($uriTemplateVars);
    }
    //FIXME work around for the the uri template lib which url encodes
    // the @'s & confuses our servers.
    $requestUrl = str_replace('%40', '@', $requestUrl);

    if (count($queryVars)) {
      $requestUrl .= '?' . implode($queryVars, '&');
    }

    return $requestUrl;
  }
936326
public void route(HttpMethods meth, String path, API api, Code code) throws Exception {
		String version = "1.0";
		// Get Correct API Class from Mapper
		Class<?> respCls = facade1_0.mapper().getClass(api); 
		if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
		// setup Application API HTML ContentTypes for JSON and Route
		String application = applicationJSON(respCls, version);
		route(env,meth,path,code,application,"application/json;version="+version,"*/*");

		// setup Application API HTML ContentTypes for XML and Route
		application = applicationXML(respCls, version);
		route(env,meth,path,code.clone(facade1_0_XML),application,"application/xml;version="+version);
		
		// Add other Supported APIs here as created
	}
1327868
function HttpRoute(route) {
    if (typeof route === 'string') {
        this.route = { url:route };
    }
    else if (typeof route === 'object') {
        this.route = route;
    }
    this.routeData = { };

    this.patterns = {
        int:function() {
            return "^[1-9]([0-9]*)$";
        },
        boolean:function() {
            return "^true|false$"
        },
        decimal:function() {
            return "^[+-]?[0-9]*\\.?[0-9]*$";
        },
        float:function() {
            return "^[+-]?[0-9]*\\.?[0-9]*$";
        },
        guid:function() {
            return "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$";
        },
        plural: function() {
            return "^[a-zA-Z]+$";
        },
        string: function() {
            return "^'(.*)'$"
        },
        date:function() {
            return "^(datetime)?'\\d{4}-([0]\\d|1[0-2])-([0-2]\\d|3[01])(?:[T ](\\d+):(\\d+)(?::(\\d+)(?:\\.(\\d+))?)?)?(?:Z(-?\\d*))?([+-](\\d+):(\\d+))?'$";
        },
    };

    this.parsers = {
        int:function(v) {
            return parseInt(v);
        },
        boolean:function(v) {
            return (/^true$/ig.test(v));
        },
        decimal:function(v) {
            return parseFloat(v);
        },
        float:function(v) {
            return parseFloat(v);
        },
        plural:function(v) {
            return pluralize.singular(v);
        },
        string:function(v) {
            return v.replace(/^'/,'').replace(/'$/,'');
        },
        date:function(v) {
            return new Date(Date.parse(v.replace(/^(datetime)?'/,'').replace(/'$/,'')));
        }
    }

}
407074
function RestAPI() {
  this.models = {};
  this.router = express.Router();
  this.router.use(require('res-error')({
    log: false
  }));
}