Releases: soveran/toro
Use Process.on_interrupt instead of Signal::INT.trap
A new way of configuring the server
The server no longer listens by default, and the call to
run
does not require a port number to be passed. This
allows for more flexibility when configuring the server.
If App
is an instance of Toro
, then a call to App.run
will
yield an instance of HTTP://Server
that you can configure.
For example, you can start the server on port 80:
App.run do |server|
server.listen "0.0.0.0", 80
end
The following example shows how to configure SSL certificates:
App.run do |server|
ssl = OpenSSL::SSL::Context::Server.new
ssl.private_key = "path/to/private_key"
ssl.certificate_chain = "path/to/certificate_chain"
server.tls = ssl
server.listen "0.0.0.0", 443
end
Configurable Server
If App
is an instance of Toro
, then you can start the server
by calling App.run
. You can pass any options you would use with
the HTTP::Server
constructor from the standard library.
For example, you can start the server on port 80:
App.run(80)
Or you can further configure server by using a block. The following
example shows how to configure SSL certificates:
App.run(443) do |server|
ssl = OpenSSL::SSL::Context::Server.new
ssl.private_key = "path/to/private_key"
ssl.certificate_chain = "path/to/certificate_chain"
server.tls = ssl
end
Refer to Crystal's documentation for more options.
JSON helper
Toro gains a json
helper. If you require "json"
from the standard library, you can use the json
helper with any generic Crystal object. Thanks @RayDF for this feature!
Ridiculous speedup
I felt Toro was fast, but then I got a pull request from @RayDF where he got rid of the workflow around raising the Halt
exception, something Toro was using for stopping the execution once a match was found. Instead, he added a flag (the @halt
instance variable) to keep track if a match had occurred. The result was an increase in performance of around 40%. The final version doesn't need the flag, as we were able to replace part of the API with a set of macros and the behavior is more in line with that of the first release. Huge thanks to @RayDF for his awesome work :-)