开发者

PHP to Rails 3 routing

开发者 https://www.devze.com 2023-01-14 16:35 出处:网络
We have a \"legacy\" flash application relying on PHP to deliver it\'s data, but the server side is now being upgraded to Rails 3.

We have a "legacy" flash application relying on PHP to deliver it's data, but the server side is now being upgraded to Rails 3.

Fo开发者_如何学JAVAr various reasons we don't want to change the flash, so we need to be able to route http requests like this: http://www.example.com/somefile.php?param=123&otherone=123457 to RESTful rails routes.

I cant assume Apache is going to be used so I cant use mod_rewrite.

Does anyone know of a good solution? Rack Middleware was my first thought.


Take a look at rack-rewrite. I bet you will be able to accomplish what you're looking for using it.

http://github.com/jtrupiano/rack-rewrite

You may not even need the gem. With a little parsing you can probably do what you're trying to do as your own custom Rack module.


If you want to "roll your own", I suggest you make a Middleware class. In this class you will be able to manipulate all environment variables before the Rails routing is executed. I've previously made an example to make all routing case insensitive (by always downcasing the URI).

have a look here:

http://gehling.dk/2010/02/how-to-make-rails-routing-case-insensitive/

Hope it's helpful.

/Carsten

0

精彩评论

暂无评论...
验证码 换一张
取 消