class Fyb::Middleware::Timestamper

Add timestamp to the request

Public Class Methods

new(app) click to toggle source
# File lib/fyb/middleware/timestamper.rb, line 7
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/fyb/middleware/timestamper.rb, line 11
def call(env)
  body = env['weary.request'].body

  timestamp = "timestamp=#{Time.now.to_i}"
  timestamp = '&' + timestamp if body.length > 0

  env['rack.input'].write(body.string)
  env['rack.input'].write(timestamp)
  env['rack.input'].rewind

  @app.call(env)
end