Disable grails Searchable plugin default search page?

前端 未结 1 1119
一整个雨季
一整个雨季 2021-01-13 02:32

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, prefer

相关标签:
1条回答
  • 2021-01-13 03:20

    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.

    0 讨论(0)
提交回复
热议问题