Class: Nile::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/nile/framework.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Core



60
61
62
63
64
65
# File 'lib/nile/framework.rb', line 60

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

#routerObject

Returns the value of attribute router.



58
59
60
# File 'lib/nile/framework.rb', line 58

def router
  @router
end

Instance Method Details

#delete(url, &block) ⇒ Object



79
80
81
# File 'lib/nile/framework.rb', line 79

def delete url, &block
    @router.add_route "DELETE", url, block
end

#get(url, &block) ⇒ Object



67
68
69
# File 'lib/nile/framework.rb', line 67

def get url, &block
    @router.add_route "GET", url, block
end

#post(url, &block) ⇒ Object



71
72
73
# File 'lib/nile/framework.rb', line 71

def post url, &block
    @router.add_route "POST", url, block
end

#put(url, &block) ⇒ Object



75
76
77
# File 'lib/nile/framework.rb', line 75

def put url, &block
    @router.add_route "PUT", url, block
end

#runObject



83
84
85
# File 'lib/nile/framework.rb', line 83

def run
    @http.serve
end