-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start-proxy.rb as app entry point, reads YAML file for config
- Loading branch information
Showing
4 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
require 'rack' | ||
require_relative './fhir-proxy.rb' | ||
|
||
# rackup config.ru -p 9292 -o 0.0.0.0 | ||
# FHIR_PROXY_BACKEND="https://r4.smarthealthit.org" rackup config.ru -p 9292 -o 0.0.0.0 | ||
run FHIRProxy.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
:Host: 0.0.0.0 | ||
:Port: 9292 | ||
:backend: https://r4.smarthealthit.org | ||
:db: fhir-transactions.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'rack' | ||
require 'yaml' | ||
require_relative './fhir-proxy.rb' | ||
|
||
# Options for Rack are listed here | ||
# https://github.com/rack/rack/blob/master/lib/rack/server.rb | ||
# | ||
begin | ||
proxy_options = YAML.load_file('proxy.yml') | ||
rescue Errno::ENOENT | ||
puts "Could not find file 'proxy.yml'" | ||
puts 'Creating one with default values' | ||
proxy_options = { | ||
Host: '0.0.0.0', | ||
Port: 9292, | ||
backend: 'https://r4.smarthealthit.org', | ||
db: 'fhir-transactions.db' | ||
} | ||
File.write('proxy.yml', proxy_options.to_yaml) | ||
end | ||
Rack::Server.start( | ||
app: FHIRProxy.new( | ||
'backend': proxy_options[:backend], | ||
'db': proxy_options[:db] | ||
), | ||
Host: proxy_options[:Host], | ||
Port: proxy_options[:Port] | ||
) |