Class: Nile::Core
- Inherits:
-
Object
- Object
- Nile::Core
- Defined in:
- lib/nile/framework.rb
Instance Attribute Summary collapse
-
#router ⇒ Object
Returns the value of attribute router.
Instance Method Summary collapse
- #delete(url, &block) ⇒ Object
- #get(url, &block) ⇒ Object
-
#initialize(args = {}) ⇒ Core
constructor
A new instance of Core.
- #post(url, &block) ⇒ Object
- #put(url, &block) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Core
Returns a new instance of Core.
59 60 61 62 63 64 |
# File 'lib/nile/framework.rb', line 59 def initialize args={} args[:port] ||= 7125 args[:bind] ||= '127.0.0.1' @http = Nile::HttpServer.new args[:bind], args[:port], HttpHandler.new @router = Router.instance end |
Instance Attribute Details
#router ⇒ Object
Returns the value of attribute router.
57 58 59 |
# File 'lib/nile/framework.rb', line 57 def router @router end |
Instance Method Details
#delete(url, &block) ⇒ Object
78 79 80 |
# File 'lib/nile/framework.rb', line 78 def delete url, &block @router.add_route "DELETE", url, block end |
#get(url, &block) ⇒ Object
66 67 68 |
# File 'lib/nile/framework.rb', line 66 def get url, &block @router.add_route "GET", url, block end |
#post(url, &block) ⇒ Object
70 71 72 |
# File 'lib/nile/framework.rb', line 70 def post url, &block @router.add_route "POST", url, block end |
#put(url, &block) ⇒ Object
74 75 76 |
# File 'lib/nile/framework.rb', line 74 def put url, &block @router.add_route "PUT", url, block end |
#run ⇒ Object
82 83 84 |
# File 'lib/nile/framework.rb', line 82 def run @http.serve end |