nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.83k stars 304 forks source link

serve a customizable page for index URL "/" #26

Closed ogoudron closed 13 years ago

ogoudron commented 13 years ago

I would like to use webdis to serve HTML5 app based on redis. The webdis URL scheme "/command/arg0/arg1" is ok for my use except i would like to be able to customize the index URL "/" for serving my one file html app.

What do you think about this ?

nicolasff commented 13 years ago

Hi Olivier,

I think this is a great idea. I'd like to keep the spirit of Webdis by not loading a file from disk though, so it will probably have to go through Redis. What do you think of this, in the config file?

"default_root": "/GET/index.html"

That gives you control over the key and the file type. If you want your root to be an XML file or a text file, that's up to you.
I can add this in a few hours if you don't have any more comments.

ogoudron commented 13 years ago

This solution is ok for me only if i can force this key to be readonly for security reason. My first idea was to include the file in the config file and to read the content of this file only at startup.

nicolasff commented 13 years ago

Webdis doesn't have any concept of keys, any sequence of commands is sent as-is to Redis. You'll have to disable the SET command, and probably some others in order to have a safe service.
You're probably better off disabling all the commands for everyone and enabling only the ones you need. I'll add a second, “read-only” config file to the repository to show you how to do it.

ogoudron commented 13 years ago

I need to let the SET command enabled. Finaly, i do not need that the key to be readonly because i can use an unguessable key. For example : "default_root": "/GET/rilfdjfsdufffyfijiifrfefef.html" I will disable some command like KEYS for example. So your solution is OK for me if you do not respond to the "/" URL by a rediction to "/GET/rilfdjfsdufffyfijiifrfefef.html".

nicolasff commented 13 years ago

I've just pushed some code to support this feature; it doesn't redirect the client but does a transparent substitution instead.

ogoudron commented 13 years ago

Tested and it works like a charm. Many many thanks for having added this.