code: private Function<HttpRequestContext, String> createPathSubstitution(final String param, final AbstractMethod am) {
          int from = 0;
          int segment = -1;
  
          // Get the path from resource then from the method
          Path[] annotations = new Path[] { am.getResource().getAnnotation(Path.class), am.getAnnotation(Path.class) };
  
          for (Path annotation : annotations) {
              if (annotation == null)  {
                  continue;
              }
  
              int index = getSubstitutionIndex(param, annotation.value());
              if (index >= 0) {
                  segment = from + index;
              } else {
                  from += -index;
              }
          }
  
          if (segment == -1) {
              throw new IllegalArgumentException("Param not found in path: " + param);
          }
  
          final int validatedSegment = segment;
  
          return new Function<HttpRequestContext, String>() {
              @Override
              public String apply(HttpRequestContext request) {
                  return request.getPathSegments().get(validatedSegment).getPath();
              }
          };
      }
docs: Creates a substitution function for path values, such as
  <code>@RequiresPermission("resource|update|{id}")</code>