Making files on my webserver read/write

For sometime now, I have been working on an architecture where I put a webserver in front of my tomcat application server. The apache web server serves all of the static content directly from a subversion repository. Any updates, are proxied to tomcat for processing. On Tomcat, I can fairly easily create, update and delete files from subversion. It works really well for me.

However, to get a file, this meant doing a get to
http://server/svn/repository/path/file
whilst if I wanted to update the same file, I would need to send a post to
http://server/tom/servlet/repository/path/file
Not really ideal at all, obviously, to get or to update a same file, should happen at the same URL… That is restful, isn’t it?

Well, finally, I came up with a solution, that involves nothing more than a few entries in the httpd.conf, specifically:

LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine  on
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^/doc/(.*) /svnLocal/$1 [P,L]
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^/doc/(.*) /tom/servlet/$1 [P,L]

Now, my url is http://server/doc/repository/path/file and the file, or any other http operation except post is served direct from subversion, but posts will be redirected to tomcat, where I can validate and save the changes.

Ok, I’m a geek, but I think that is cool!

Advertisements

About gregorycoburn

Enterprise Architect
This entry was posted in Rest. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s