Class: Vertx::HttpServer
- Inherits:
-
Object
- Object
- Vertx::HttpServer
- Includes:
- SSLSupport, ServerSSLSupport, ServerTCPSupport, TCPSupport
- Defined in:
- src/main/api_shim/core/http.rb
Overview
An HTTP and WebSockets server
Instance Method Summary (collapse)
-
- (Object) close(&hndlr)
Close the server.
-
- (HttpServer) initialize
constructor
Create a new HttpServer.
-
- (Object) listen(port, host = "0.0.0.0", &hndlr)
Instruct the server to listen for incoming connections.
-
- (Object) request_handler(rm = nil, &hndlr)
Set the HTTP request handler for the server.
-
- (Object) websocket_handler(&hndlr)
Set the WebSocket handler for the server.
Methods included from SSLSupport
#key_store_password, #key_store_password=, #key_store_path, #key_store_path=, #ssl, #ssl=, #trust_store_password, #trust_store_password=, #trust_store_path, #trust_store_path=
Methods included from ServerSSLSupport
#client_auth_required, #client_auth_required=
Methods included from TCPSupport
#receive_buffer_size=, #reuse_address, #reuse_address=, #send_buffer_size, #send_buffer_size=, #send_receive_size, #so_linger, #so_linger=, #tcp_keep_alive, #tcp_keep_alive=, #traffic_class, #traffic_class=, #use_pooled_buffers, #use_pooled_buffers=
Methods included from ServerTCPSupport
#accept_backlog, #accept_backlog=
Constructor Details
- (HttpServer) initialize
Create a new HttpServer
30 31 32 |
# File 'src/main/api_shim/core/http.rb', line 30 def initialize @j_del = org.vertx.java.platform.impl.JRubyVerticleFactory.vertx.createHttpServer end |
Instance Method Details
- (Object) close(&hndlr)
Close the server. The handler will be called when the close is complete.
66 67 68 69 70 71 72 |
# File 'src/main/api_shim/core/http.rb', line 66 def close(&hndlr) if hndlr @j_del.close(ARWrappedHandler.new(hndlr)) else @j_del.close end end |
- (Object) listen(port, host = "0.0.0.0", &hndlr)
Instruct the server to listen for incoming connections.
61 62 63 |
# File 'src/main/api_shim/core/http.rb', line 61 def listen(port, host = "0.0.0.0", &hndlr) @j_del.listen(port, host, ARWrappedHandler.new(hndlr) { |j_del| self }) end |
- (Object) request_handler(rm = nil, &hndlr)
Set the HTTP request handler for the server.
As HTTP requests arrive on the server a new Vertx::HttpServerRequest instance will be created and passed to the handler.
37 38 39 40 41 42 43 44 |
# File 'src/main/api_shim/core/http.rb', line 37 def request_handler(rm = nil, &hndlr) if (rm && (rm.is_a? RouteMatcher)) @j_del.requestHandler { |j_del| rm.input(HttpServerRequest.new(j_del))} else @j_del.requestHandler { |j_del| hndlr.call(HttpServerRequest.new(j_del)) } end self end |
- (Object) websocket_handler(&hndlr)
Set the WebSocket handler for the server.
As WebSocket requests arrive on the server and are accepted a new WebSocket instance will be created and
passed to the handler.
50 51 52 53 54 55 |
# File 'src/main/api_shim/core/http.rb', line 50 def websocket_handler(&hndlr) @j_del.websocketHandler do |param| hndlr.call(ServerWebSocket.new(param)) end self end |