Module: FuncE::Http
- Defined in:
- lib/func_e/http.rb
Class Method Summary collapse
- .active_pid ⇒ Object
- .headers ⇒ Object
- .kill_server ⇒ Object
- .post(func) ⇒ Object
- .start_server ⇒ Object
- .uri ⇒ Object
Class Method Details
.active_pid ⇒ Object
13 14 15 |
# File 'lib/func_e/http.rb', line 13 def self.active_pid `lsof -i:#{Config.config.local_server_port} -t`.to_i end |
.headers ⇒ Object
9 10 11 |
# File 'lib/func_e/http.rb', line 9 def self.headers { 'Content-Type': 'application/json' } end |
.kill_server ⇒ Object
29 30 31 |
# File 'lib/func_e/http.rb', line 29 def self.kill_server active_pid.tap { |pid| system("kill -9 #{pid}") unless pid.zero? } end |
.post(func) ⇒ Object
17 18 19 |
# File 'lib/func_e/http.rb', line 17 def self.post(func) Net::HTTP.post(uri, { name: func.name, payload: func.payload }.to_json, headers) end |
.start_server ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/func_e/http.rb', line 21 def self.start_server kill_server Thread.new { system("node #{FuncE::SERVER_PATH} --port=#{Config.config.local_server_port} --functions_path=#{Config.install_path}") } end |
.uri ⇒ Object
5 6 7 |
# File 'lib/func_e/http.rb', line 5 def self.uri URI("http://localhost:#{FuncE::Config.config.local_server_port}") end |