Sha256: 5111fd6d45dc0c5513030e25bf4226e39cf7e314ea7f9467072ea6c7796d61e9

Contents?: true

Size: 934 Bytes

Versions: 3

Compression:

Stored size: 934 Bytes

Contents

#!/usr/bin/env ruby

require 'optparse'

require "gitoe/httpserver/static"
require "gitoe/httpserver/repos"

handler_options = {
  Port: 3000,
  Host: '127.0.0.1',
}

OptionParser.new do |opts|
  opts.banner = "Usage: gitoe [options]"
  opts.on("-p N", "--port N", "port to listen on, default: 3000") do |port|
    handler_options[ :Port ] = port.to_i
  end
  opts.on("-o", "--open", "open to non-localhost access") do
    handler_options[ :Host ] = '0.0.0.0'
  end
end.parse!

handlers = [ :Thin, :Mongrel, :WEBrick ]
handler_name = handlers[
  handlers.find_index {|h| Rack::Handler.const_defined? h }
]

handler = Rack::Handler::const_get handler_name

root = Rack::Builder.new do

  use Rack::Deflater
  map "/repo" do run Gitoe::HTTPServer::Repos.new  end
  map "/"     do run Gitoe::HTTPServer::Static.new end

end

root = Rack::Reloader.new(root,cooldown=0) if ENV["RACK_ENV"]=="development"

handler.run root, handler_options

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gitoe-0.1.3 bin/gitoe
gitoe-0.1.2 bin/gitoe
gitoe-0.1.1 bin/gitoe