Skip to content

Commit

Permalink
provide options for specifying the server host
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen von Takach committed Feb 3, 2018
1 parent 6c66c80 commit 210e9c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: action-controller
version: 0.1.0
version: 0.1.2

dependencies:
habitat:
Expand Down
2 changes: 1 addition & 1 deletion src/action-controller.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "logger"
require "habitat"

module ActionController
VERSION = "0.1.0"
VERSION = "0.1.2"

class Error < ::Exception
end
Expand Down
6 changes: 4 additions & 2 deletions src/action-controller/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ class ActionController::Server
@server : HTTP::Server?
@route_handler = RouteHandler.new

def initialize(@port : Int32, @before_handlers = [] of HTTP::Handler, @after_handlers = [] of HTTP::Handler)
def initialize(@port : Int32, @host = "127.0.0.1", @before_handlers = [] of HTTP::Handler, @after_handlers = [] of HTTP::Handler)
end

getter :host
getter :port
getter :before_handlers
getter :after_handlers

def run
{% for klass in ActionController::Base::CONCRETE_CONTROLLERS %}
{{klass}}.draw_routes(self)
{% end %}
@server = HTTP::Server.new(@port, @before_handlers + [route_handler] + @after_handlers).listen
@server = HTTP::Server.new(@host, @port, @before_handlers + [route_handler] + @after_handlers).listen
end

def close
Expand Down

0 comments on commit 210e9c1

Please sign in to comment.