class Onyx::HTTP::Server

Overview

The Onyx HTTP server. Basically it is just a wrapper around default ::HTTP::Server, which logs server start and stop events.

server = Onyx::HTTP::Server.new(handlers)
server.bind_tcp("0.0.0.0", 5000)
server.listen

#   INFO -- : ⬛ Onyx::HTTP::Server is listening at http://0.0.0.0:5000
^C
#   INFO -- : ⬛ Onyx::HTTP::Server is shutting down!

Defined in:

onyx-http/server.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(handlers : Enumerable, **nargs, &block : ::HTTP::Handler::HandlerProc) #

[View source]
def self.new(**nargs, &block : ::HTTP::Handler::HandlerProc) #

[View source]
def self.new(*handlers : ::HTTP::Handler, **nargs, &block : ::HTTP::Handler::HandlerProc) #

[View source]
def self.new(handlers : Enumerable, **nargs) #

[View source]
def self.new(middleware : ::HTTP::Handler | ::HTTP::Handler::HandlerProc, *, name : String = "Onyx::HTTP::Server", logger : Logger? = ::Logger.new(STDOUT), logger_severity : Logger::Severity = ::Logger::INFO) #

[View source]
def self.new(*handlers : ::HTTP::Handler, **nargs) #

[View source]

Instance Method Detail

def listen #

Start listening for requests. Blocks the runtime, just like the vanilla ::HTTP::Server.


[View source]