diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-11-23 12:17:24 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-11-23 12:17:24 -0800 |
commit | b8ee33b8e38911012fc055f02da1878e45eb721a (patch) | |
tree | 48c98c0a7390fd6693a7a4440f47a46e765f4fbe /lib/metropolis/tc/hdb.rb | |
parent | df91c57c312bee97a16bced1035bd704e518ac38 (diff) | |
download | metropolis-b8ee33b8e38911012fc055f02da1878e45eb721a.tar.gz |
split out common read/write code
It will be useful when we support other backends.
Diffstat (limited to 'lib/metropolis/tc/hdb.rb')
-rw-r--r-- | lib/metropolis/tc/hdb.rb | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/lib/metropolis/tc/hdb.rb b/lib/metropolis/tc/hdb.rb index ec387b4..4c58ca8 100644 --- a/lib/metropolis/tc/hdb.rb +++ b/lib/metropolis/tc/hdb.rb @@ -6,14 +6,7 @@ module Metropolis::TC::HDB autoload :RO, 'metropolis/tc/hdb/ro' TCHDB = TokyoCabinet::HDB # :nodoc - include Rack::Utils # unescape - - def r(code) - body = "#{HTTP_STATUS_CODES[code]}\n" - [ code, - { 'Content-Length' => body.size.to_s, 'Content-Type' => 'text/plain' }, - [ body ] ] - end + include Metropolis::Common def setup(opts) @headers = { 'Content-Type' => 'application/octet-stream' } @@ -64,25 +57,6 @@ module Metropolis::TC::HDB end end - def call(env) - if %r{\A/(.*)\z} =~ env["PATH_INFO"] - key = unescape($1) - case env["REQUEST_METHOD"] - when "GET" - get(key) - when "HEAD" - head(key) - when "DELETE" - delete(key) - when "PUT" - put(key, env) - else - [ 405, {}, [] ] - end - else # OPTIONS - [ 405, {}, [] ] - end - end def ex!(msg, hdb) raise "#{msg}: #{hdb.errmsg(hdb.ecode)}" |