class

Silver::App

Inherits Reference < Object

The control-point of the application. Includes caching and server-run mechanisms.

Instance methods

add_route(method : Method, path : String, &block : Handler)

Add some route to the route list

Source
connection_handler(client : TCPSocket)
Source
create_error_400
Source
create_error_404
Source
create_request(reader : TCPSocket) : Tuple(HttpRequest | Nil, Bool)

Create some request Returns a tuple of the request itself and the status of keep-alive as bool

Source
create_response(req : HttpRequest) : Tuple(HttpResponse, File | Nil)

Create a response corresponding to a HTTP request.

Source
empty_response
Source
find_handler(req : HttpRequest) : Tuple(Handler, Hash(String, String)) | Nil

Find a handler given a request, accounting for path parameters

Source
html(method : Method, path : String, &block : Context -> String)
Source
json(method : Method, path : String, &block : Context -> String)
Source
routes
Source
run(port : Int, address : String = "0.0.0.0")
Source
write_response(res : HttpResponse, socket : TCPSocket, keep_alive : Bool) : Bool
Source