Permalink
Browse files

improve README

  • Loading branch information...
1 parent 718b7ee commit 5ff956cdace5ce682cadb98dffb530c248e468e2 @vast committed Jan 22, 2012
Showing with 25 additions and 5 deletions.
  1. +25 −5 README.md
View
@@ -2,30 +2,50 @@
`sinatra-xsendfile` extension provides `x_send_file` helper method for sending files faster
+
##XSendFile
* in [lighttpd](http://redmine.lighttpd.net/projects/1/wiki/X-LIGHTTPD-send-file);
* in [apache](http://tn123.ath.cx/mod_xsendfile/);
* in [nginx](http://wiki.nginx.org/NginxXSendfile).
+##Installation
+
+If you use [bundler](http://gembundler.com/), simply specify
+`sinatra-xsendfile` as a dependency in a Gemfile in your project's root:
+
+ gem 'sinatra-xsendfile'
+
+and run `bundle install`.
+
+Otherwise install the gem as usual:
+
+ [sudo] gem install sinatra-xsendfile
+
+
##Example
require 'rubygems'
require 'sinatra'
require 'sinatra-xsendfile'
configure :production do
- Sinatra::Xsendfile.replace_send_file! #replaces sinatra's send_file with x_send_file
- set :xsf_header, 'X-Accel-Redirect' #setting default(X-SendFile) header (nginx)
+ Sinatra::Xsendfile.replace_send_file! # replace Sinatra's send_file with x_send_file
+ set :xsf_header, 'X-Accel-Redirect' # set x_send_file header (default: X-SendFile)
end
get '/' do
x_send_file(__FILE__)
end
- get '/nginx' do
- x_send_file(__FILE__, :header => 'X-LIGHTTPD-send-file')
+ get '/lighttpd' do
+ x_send_file(__FILE__, :header => 'X-LIGHTTPD-send-file') # custom header
end
get '/sendfile' do
- send_file(__FILE__) #will work as x_send_file in production
+ send_file(__FILE__) # will work as x_send_file in production (see configure block)
end
+
+*Note* that if your application subclasses `Sinatra::Base` (modular app),
+you have to register the extension in your subclass:
+
+ helpers Sinatra::Xsendfile

0 comments on commit 5ff956c

Please sign in to comment.