Skip to content

class ActionController::Server
inherits Reference #

Included modules

ActionController::Router

Constants#

REUSE_DEFAULT = {% if flag?(:win32) %} false {% else %} true {% end %}#

reuse port is only useful for broadcast or multicast applications on windows when used with TCP it is considered a security risk as the port can be stolen

Constructors#

.new(port : Int32 = 3000, host : String = "127.0.0.1", reuse_port : Bool = REUSE_DEFAULT)#

create an instance of the application

View source

.new(ssl_context : OpenSSL::SSL::Context::Server | Nil, port : Int32 = 3000, host : String = "127.0.0.1", reuse_port : Bool = REUSE_DEFAULT)#

create an instance of the application with tls

View source

Class methods#

.after(*handlers)#

handlers to run after your application code, see: handlers

these will only be run if the route is not found in your application

View source

.before(*handlers)#

handlers to run before your application code, see: handlers

configure these in your config.cr file

View source

.print_routes#

Used to output route details to the console from a command line switch

View source

.routes : Array(Tuple(String, Symbol, Symbol, String))#

returns a list of the routes defined in the application

responds with [{"ControllerClass", :name, :verb, "/route"}]

View source

Methods#

#close : Nil#

Terminates the application gracefully once any cluster processes have exited

View source

#cluster(count, short_arg, long_arg, args = ARGV.dup)#

Launches additional worker processes removing the short and long arguments that trigger this method

View source

#cluster(count)#

Spawns count number of threads in the default Fiber::ExecutionContext

View source

#host#

the host address the server is configured to run on

View source

#port#

the port the server is accepting connections from

View source

#print_addresses#

Prints the addresses that the server is listening on

View source

#run : Nil#

Starts the server, providing a callback once the ports are bound

View source

#run : Nil#

Starts the server

View source

#socket : HTTP::Server#

Provides access the HTTP server for the purpose of binding For example server.socket.bind_unix "/tmp/my-socket.sock"

View source

#threads(count = -1)#

Spawns count number of threads in the default Fiber::ExecutionContext

View source