Method: Roby::Application#setup_rest_interface
- Defined in:
- lib/roby/app.rb
#setup_rest_interface ⇒ Object
Publishes a REST API
The REST API will long-term replace the shell interface. It is however currently too limited for this purpose. Whether one should use one or the other is up to the application, but prefer the REST API if it suits your needs
2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 |
# File 'lib/roby/app.rb', line 2299 def setup_rest_interface require "roby/interface/rest" if @rest_interface raise "there is already a REST interface started, call #stop_rest_interface first" end composite_api = Class.new(Grape::API) composite_api.mount Interface::REST::API call_plugins(:setup_rest_interface, self, composite_api) @rest_interface = Interface::REST::Server.new( self, host: rest_interface_host, port: rest_interface_port, api: composite_api ) @rest_interface.start if rest_interface_port != Interface::DEFAULT_REST_PORT Robot.info "REST interface started on port #{@rest_interface.port(timeout: nil)}" else Robot.debug "REST interface started on port #{rest_interface_port}" end @rest_interface end |