Class: PostRemoteLog::Server
- Inherits:
-
Object
- Object
- PostRemoteLog::Server
- Defined in:
- lib/post_remote_log/server.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(config = {}) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(config = {}) ⇒ Server
Returns a new instance of Server.
22 23 24 25 26 27 |
# File 'lib/post_remote_log/server.rb', line 22 def initialize(config = {}) @dump_dir = config[:dump_path] $stderr.puts "Dumping data to #{@dump_dir}" FileUtils.mkdir_p(@dump_dir) end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/post_remote_log/server.rb', line 29 def call(env) request = Rack::Request.new(env) if request.post? data = request.body().read() now = Time.now file_name = "#{now.strftime('%Y%m%d_%H%M%S')}_#{now.usec}.xml" full_path = File.join(@dump_dir, file_name) $stderr.puts "Writing data to #{file_name}..." File.open(full_path, "w") { |f| f.write(data) } end return [200, {}, []] end |