5

I'm trying to disable the Searchable plugin default search page (http://localhost/searchable/), but haven't found a way to do it. Anyone know how this can be done, preferably in a legit way, but resorting to trickery if necessary?

Kaleb Brasee
  • 51,193
  • 8
  • 108
  • 113

1 Answers1

4

I usually re-route error code handlers to a controller so I can do some logging or whatever before rendering the view. You can use that here also:

class UrlMappings {

   static mappings = {

      "/searchable/$action?"(controller: "errors", action: "urlMapping")

      "/$controller/$action?/$id?" { }

      "/"(view:"/index")

      "403"(controller: "errors", action: "accessDenied")
      "404"(controller: "errors", action: "notFound")
      "405"(controller: "errors", action: "notAllowed")
      "500"(view: '/error')
   }
}

where ErrorsController looks something like this:

class ErrorsController {

   def accessDenied = {}

   def notFound = {
      log.debug "could not find $request.forwardURI"
   }

   def notAllowed = {}

   def urlMapping = {
      log.warn "unexpected call to URL-Mapped $request.forwardURI"
      render view: 'notFound'
   }
}

and you'll need to create accessDenied.gsp, notFound.gsp, and notAllowed.gsp in grails-app/errors

By sending a 'hidden' controller to its custom mapping you can log unexpected access to it, but still render the 404 page to hide its existence.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
  • That's a good idea, then I can make it just look like any other resource not found error. I like it! I had created a /views/searchable/index.gsp to overwrite the one included with the plugin, but I'll just get rid of that and do it this way. Thanks! – Kaleb Brasee Jul 04 '10 at 03:47
  • @Burt - is there some way to just disable/remove the UrlMapping at startup? That would be a much more elegant solution. – Ken Liu Jan 22 '12 at 23:23
  • You probably could remove it, but I doubt it'd be a simple fix. Seems like a good candidate for a feature request. It could probably get implemented when we do controller namespaces (tentatively v2.2). – Burt Beckwith Jan 22 '12 at 23:30
  • Don't forget to add the following URI or else it is still open: `"/searchable"(controller: "errors", action: "urlMapping")` – rwyland Oct 10 '12 at 17:56