Rewrite URL (/:resource/:id/:nested -> /:nested) and request body
338581
function post (req, res, next) {
    var prop = pluralize.singular(req.params.resource)
    req.body[prop + 'Id'] = utils.toNative(req.params.id)
    req.url = '/' + req.params.nested
    next()
  }
1262774
def replacer
        lambda do |resource_id, _graph|
          parent_id = ActiveFedora::Base.uri_to_id(parent_url)
          return parent_url + resource_id.sub(parent_id, '') if resource_id.start_with?(parent_id)
          Rails.application.routes.url_helpers.solr_document_url(resource_id, host: hostname)
        end
      end
1226877
function get (req, res, next) {
    var prop = pluralize.singular(req.params.resource)
    req.query[prop + 'Id'] = utils.toNative(req.params.id)
    if (!req.query._filter) {
      req.query._filter = prop + 'Id=' + req.params.id
    } else {
      req.query._filter += ',' + prop + 'Id=' + req.params.id
    }
    req.url = '/' + req.params.nested
    next()
  }
771580
def build_url(self):
        
        url = '{protocol}/{url}/{rest}/{version}/{restapi}/{rscpath}/' \
              '{query}'.format(protocol=self.schema.protocol,
                               url=self.schema.main_url,
                               rest=self.schema.rest,
                               version=self.schema.version,
                               restapi=self.schema.restApi,
                               rscpath=self.schema.resourcePath,
                               query=self.schema.query)
        return url.replace('/None/', '/')
925526
def rewrite(self, path, expand, newmethod = None, host = None, vhost = None, method = [b'GET', b'HEAD'], keepquery = True):
        ""
        async def func(env):
            newpath = self.expand(env.path_match, expand)
            if keepquery and getattr(env, 'querystring', None):
                if b'?' in newpath:
                    newpath += b'&' + env.querystring
                else:
                    newpath += b'?' + env.querystring
            await env.rewrite(newpath, newmethod)
        self.route(path, func)
645621
def post(path, body = '', headers = {})
      headers = { 'Content-Type' => 'application/json' }.merge(headers)
      request(:post, path, body, merge_default_headers(headers))
    end
1042180
def get_url(self, resource, params=None):
        

        # replace placeholders

        pattern = r'\{(.+?)\}'

        resource = re.sub(pattern, lambda t: str(params.get(t.group(1), '')), resource)

        # build url

        parts = (self.endpoint, '/api/', resource)
        return '/'.join(map(lambda x: str(x).strip('/'), parts))
925245
function Resource(url, params, actions, options$$1) {

    var self = this || {}, resource = {};

    actions = assign({},
        Resource.actions,
        actions
    );

    each(actions, function (action, name) {

        action = merge({url: url, params: assign({}, params)}, options$$1, action);

        resource[name] = function () {
            return (self.$http || Http)(opts(action, arguments));
        };
    });

    return resource;
}
411961
def res_to_url(resource, action):
    """"""
    i = action.find("_")
    if i < 0:
        url = "/" + resource
        httpmethod = action
    else:
        url = "/%s/%s" % (resource, action[i + 1:])
        httpmethod = action[:i]
    return url, httpmethod.upper()
1367807
def api_url
      @api_url ||= Addressable::URI.new(
        :scheme => scheme, :host => host, :port => port,
        :path => path_with_base("/_api", resource_path)
      ).normalize.to_s
    end
217627
def get(*args)
      url, subdomain, path, params = parse_args(*args)
      JSON.parse(
        rewrap_errors do
          RestClient.get(
            build_url(url || subdomain, path, params),
            headers).body
        end, symbolize_names: true)
    end
61154
def url_for(params)
      host_with_port = host || location.host
      host_with_port += ":#{port}" if port && port != 80
      scheme = scheme || location.scheme

      unless RUBY_PLATFORM == 'opal'
        # lazy load routes and views on the server
        if !@router && @routes_loader
          # Load the templates
          @routes_loader.call
        end
      end

      path, params = @router.params_to_url(params)

      if path == nil
        raise "No route matched, make sure you have the base route defined last: `client '/', {}`"
      end

      new_url    = "#{scheme}://#{host_with_port}#{path.chomp('/')}"

      # Add query params
      params_str = ''
      unless params.empty?
        query_parts = []
        nested_params_hash(params).each_pair do |key, value|
          # remove the _ from the front
          value = Volt::Parsing.encodeURI(value)
          query_parts << "#{key}=#{value}"
        end

        if query_parts.size > 0
          query = query_parts.join('&')
          new_url += "?#{query}"
        end
      end

      # Add fragment
      frag    = fragment
      new_url += '#' + frag if frag.present?

      new_url
    end
817143
def _route(self, args, request=None):
        '''
        
        '''
        if request is None:
            from pecan import request
        # convention uses "_method" to handle browser-unsupported methods
        method = request.params.get('_method', request.method).lower()

        # make sure DELETE/PUT requests don't use GET
        if request.method == 'GET' and method in ('delete', 'put'):
            abort(405)

        # check for nested controllers
        result = self._find_sub_controllers(args, request)
        if result:
            return result

        # handle the request
        handler = getattr(
            self,
            '_handle_%s' % method,
            self._handle_unknown_method
        )

        try:
            if len(getargspec(handler).args) == 3:
                result = handler(method, args)
            else:
                result = handler(method, args, request)

            #
            # If the signature of the handler does not match the number
            # of remaining positional arguments, attempt to handle
            # a _lookup method (if it exists)
            #
            argspec = self._get_args_for_controller(result[0])
            num_args = len(argspec)
            if num_args < len(args):
                _lookup_result = self._handle_lookup(args, request)
                if _lookup_result:
                    return _lookup_result
        except (exc.HTTPClientError, exc.HTTPNotFound,
                exc.HTTPMethodNotAllowed) as e:
            #
            # If the matching handler results in a 400, 404, or 405, attempt to
            # handle a _lookup method (if it exists)
            #
            _lookup_result = self._handle_lookup(args, request)
            if _lookup_result:
                return _lookup_result

            # Build a correct Allow: header
            if isinstance(e, exc.HTTPMethodNotAllowed):

                def method_iter():
                    for func in ('get', 'get_one', 'get_all', 'new', 'edit',
                                 'get_delete'):
                        if self._find_controller(func):
                            yield 'GET'
                            break
                    for method in ('HEAD', 'POST', 'PUT', 'DELETE', 'TRACE',
                                   'PATCH'):
                        func = method.lower()
                        if self._find_controller(func):
                            yield method

                e.allow = sorted(method_iter())

            raise

        # return the result
        return result
393758
function RouteRule_createUrl(route, params) {
        var escape = [], i, len, c, url;

        if (this.route !== route) {
            if (!this.routeRule) {
                return false;
            }
            escape = this.match(this.routeRule, this.trim(route, '/'));
            if (!escape.length) {
                return false;
            }
            escape.forEach(function (item) {
                if (item.key.indexOf('<') === -1) {
                    item.key = '<' + item.key + '>';
                }
            });
        }

        len = this.paramRules.length;

        for (i = 0; i < len; ++i) {
            c = this.paramRules[i];
            if (params.hasOwnProperty(c.key) && (c.value === '' || (Type.isRegExp(c.value) && c.value.test(params[c.key])) || this.match(c.value, params[c.key].toString()).length > 0)) {
                escape.push({
                    key: '<' + c.key + '>',
                    value: params[c.key].toString()
                });
                delete params[c.key];
            } else if (Type.isUndefined(params[c.key])) {
                return false;
            }
        }

        url = this.trim(this.escape(this.template, escape), '/');

        if (this.match(this.pattern.regex, url).length === 0) {
            return false;
        }

        if (Object.keys(params).length > 0) {
            url += "?" + this.buildQuery(params);
        }
        return url;
    }
163597
def _build_url_rewriter(cls, session: AppSession):
        ''''''
        if session.args.escaped_fragment or session.args.strip_session_id:
            return session.factory.new(
                'URLRewriter',
                hash_fragment=session.args.escaped_fragment,
                session_id=session.args.strip_session_id
            )
1073781
def post(path, options = {}, headers = {}, raw = false)
      request(:post, path, options, headers, raw)
    end
583880
def build_request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash
      opts    = @default_options.merge(opts)
      uri     = make_request_uri(uri, opts)
      headers = make_request_headers(opts)
      body    = make_request_body(opts, headers)

      req = HTTP::Request.new(
        :verb           => verb,
        :uri            => uri,
        :uri_normalizer => opts.feature(:normalize_uri)&.normalizer,
        :proxy          => opts.proxy,
        :headers        => headers,
        :body           => body
      )

      opts.features.inject(req) do |request, (_name, feature)|
        feature.wrap_request(request)
      end
    end