title: Spring Data Rest Add custom endpoint to specific reposiotry
body: <p>I would like to add a custom search endpoint to my existing user repository.</p>
  
  <p>My user Repository looks like this:</p>
  
  <pre><code>@RepositoryRestResource(collectionResourceRel="users", path="users")
  public interface UserRepository extends PagingAndSortingRepository&lt;User, Long&gt;{
  
      User findByUsername(String username);
  }
  </code></pre>
  
  <p>The custom controller:</p>
  
  <pre><code>@BasePathAwareController 
  @RequestMapping("users/search")
  public class CustomController implements ResourceProcessor&lt;RepositorySearchesResource&gt;, ResourceAssembler&lt;User, Resource&lt;User&gt;&gt; {
      @Autowired
      UserRepository userReposiotry;
      @Autowired
      private EntityLinks entityLinks;
  
      @RequestMapping(value = "findFirst", produces = "application/json")
      @ResponseBody
      public ResponseEntity&lt;Resource&lt;User&gt;&gt; findFirstUser() {
            Resource&lt;User&gt; resource = toResource(userReposiotry.findOne(1L));
            return new ResponseEntity&lt;Resource&lt;User&gt;&gt;(resource, HttpStatus.OK);
      }
  
      @Override
      public RepositorySearchesResource process(RepositorySearchesResource resource) {
          LinkBuilder lb = entityLinks.linkFor(User.class, "username");
          resource.add(new Link(lb.toString() + "/search/findFirst", "findFirst"));
          return resource;
      }
  
      @Override
      public Resource&lt;User&gt; toResource(User user) {
          Resource&lt;User&gt; resource = new Resource&lt;User&gt;(user);
          return resource;
      }
  }
  </code></pre>
  
  <p>This returns the correct search endpoint for the users:</p>
  
  <pre><code>{
    "_links": {
      "findByUsername": {
        "href": "http://localhost:8080/api/users/search/findByUsername"
      },
      "self": {
        "href": "http://localhost:8080/api/users/search"
      },
      "findFirst": {
        "href": "http://localhost:8080/api/users/search/findFirst",
        "templated": true
      }
    }
  }
  </code></pre>
  
  <p>But also for other endpoints like Invites:</p>
  
  <pre><code>{
    "_links": {
      "findUserByInvite": {
        "href": "http://localhost:8080/api/invites/search/findUserByInvite"
      },
      "self": {
        "href": "http://localhost:8080/api/invites/search"
      },
      "findFirst": {
        "href": "http://localhost:8080/api/invites/search/findFirst",
        "templated": true
      }
    }
  }
  </code></pre>
  
  <p>How can this be restricted to the users only?
  Thanks</p>