Class: RailsMarkup::HttpServer
- Inherits:
-
Object
- Object
- RailsMarkup::HttpServer
- Defined in:
- lib/rails_markup/http_server.rb
Overview
HTTP server providing REST API + SSE for the browser-side annotation controller. Wire-compatible with Agentation's HTTP API.
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(store:, port: 4747, logger: nil) ⇒ HttpServer
constructor
A new instance of HttpServer.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(store:, port: 4747, logger: nil) ⇒ HttpServer
Returns a new instance of HttpServer.
12 13 14 15 16 |
# File 'lib/rails_markup/http_server.rb', line 12 def initialize(store:, port: 4747, logger: nil) @store = store @port = port @logger = logger || WEBrick::Log.new($stderr, WEBrick::Log::WARN) end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
10 11 12 |
# File 'lib/rails_markup/http_server.rb', line 10 def port @port end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
10 11 12 |
# File 'lib/rails_markup/http_server.rb', line 10 def store @store end |
Instance Method Details
#shutdown ⇒ Object
34 35 36 |
# File 'lib/rails_markup/http_server.rb', line 34 def shutdown @server&.shutdown end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rails_markup/http_server.rb', line 18 def start @server = WEBrick::HTTPServer.new( Port: @port, Logger: @logger, AccessLog: [], DoNotReverseLookup: true ) @server.mount("/", CorsServlet, @store) trap("INT") { @server.shutdown } trap("TERM") { @server.shutdown } @server.start end |