Module: Sharp::Rack
- Included in:
- Application
- Defined in:
- lib/sharp/rack.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DEFAULT_ENV =
{ "SCRIPT_NAME" => "", "SERVER_NAME" => "localhost", "SERVER_PORT" => "80", "HTTP_HOST" => "localhost", "HTTP_ACCEPT" => "*/*", "HTTP_USER_AGENT" => "Sharp #{VERSION}", "rack.input" => StringIO.new, "rack.errors" => StringIO.new, "rack.url_scheme" => "http" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #delete(path, env = {}) ⇒ Object
- #get(path, env = {}) ⇒ Object
- #head(path, env = {}) ⇒ Object
- #post(path, env = {}) ⇒ Object
- #put(path, env = {}) ⇒ Object
- #route(method, path, env = {}) ⇒ Object
- #router ⇒ Object
Class Method Details
.included(cls) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/sharp/rack.rb', line 15 def self.included(cls) cls.class_eval do extend ClassMethods attr_writer :router end end |
Instance Method Details
#delete(path, env = {}) ⇒ Object
55 56 57 |
# File 'lib/sharp/rack.rb', line 55 def delete(path, env={}) router.call(self.class.env(:delete, path, env={})) end |
#get(path, env = {}) ⇒ Object
43 44 45 |
# File 'lib/sharp/rack.rb', line 43 def get(path, env={}) router.call(self.class.env(:get, path, env={})) end |
#head(path, env = {}) ⇒ Object
59 60 61 |
# File 'lib/sharp/rack.rb', line 59 def head(path, env={}) router.call(self.class.env(:head, path, env={})) end |
#post(path, env = {}) ⇒ Object
47 48 49 |
# File 'lib/sharp/rack.rb', line 47 def post(path, env={}) router.call(self.class.env(:post, path, env={})) end |
#put(path, env = {}) ⇒ Object
51 52 53 |
# File 'lib/sharp/rack.rb', line 51 def put(path, env={}) router.call(self.class.env(:put, path, env={})) end |
#route(method, path, env = {}) ⇒ Object
39 40 41 |
# File 'lib/sharp/rack.rb', line 39 def route(method, path, env={}) router.match(self.class.env(method, path, env={})) end |
#router ⇒ Object
35 36 37 |
# File 'lib/sharp/rack.rb', line 35 def router @router ||= ::Rack::Router.new end |