local request

Hi everybody!

Does anyone know the best approach to create local-only path?

====code begin====

MyApp::Application.routes.draw do
  match 'quicksearch' => 'application#quicksearch'

===code end===

I want the path '\quicksearch' to be exactly local (available from application itself only), any external requests must be ignored.

The first thing came into my mind is to create small request filter based on IP (?). Of course...
Filter can be route-level or middleware-level, but anywhere.. IP address as a base of distinction seems to me not so good.

Any opinions, folks?

Then why even bother to access it through a controller?

If the javascript runtime could do it… :slight_smile:

I’ve never done something like this before (routing to application controller), but weeks ago I saw this project in this mail list


and in its routes file he made something like you mentioned.

Maybe you can use it as an example.

Javier Q.

JavaScript? Is this executing on the client or on the server?

Oops, I just realized that javascript code executing always on client’s browser, and any request will have ‘REMOTE_ADDR’ = client’s IP. Thus, there is only approach to use some kind of authenticity_token.