faraday/script/server
Mattia aa4e33ff50 chore: Fix RuboCop Style/HashSyntax (#878)
* Fixes rubocop Style/HashSyntax issues.

* Fixes rubocop Style/HashSyntax issues in comments as well.
2019-02-26 12:10:35 +01:00

39 lines
914 B
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
old_verbose, $VERBOSE = $VERBOSE, nil
begin
require File.expand_path('../../test/live_server', __FILE__)
ensure
$VERBOSE = old_verbose
end
require 'webrick'
port = 4000
if (found = ARGV.index('-p'))
port = ARGV[found + 1].to_i
end
log_io = $stdout
log_io.sync = true
webrick_opts = {
Port: port, Logger: WEBrick::Log::new(log_io),
AccessLog: [[log_io, '[%{X-Faraday-Adapter}i] %m %U -> %s %b']]
}
if ENV['SSL_KEY']
require 'openssl'
require 'webrick/https'
webrick_opts.update \
SSLEnable: true,
SSLPrivateKey: OpenSSL::PKey::RSA.new(File.read(ENV['SSL_KEY'])),
SSLCertificate: OpenSSL::X509::Certificate.new(File.read(ENV['SSL_FILE'])),
SSLVerifyClient: OpenSSL::SSL::VERIFY_NONE
end
Rack::Handler::WEBrick.run(Faraday::LiveServer, webrick_opts) do |server|
trap(:INT) { server.stop }
trap(:TERM) { server.stop }
end