Sha256: c08ac3b45ee4125534c9bdb1945167ae1d0a9a08e7d02dec97c270ebac0e9494
Contents?: true
Size: 935 Bytes
Versions: 3
Compression:
Stored size: 935 Bytes
Contents
require 'json' require 'alephant/logger' module Alephant module Broker class Environment include Logger attr_reader :settings def initialize(env) @settings = env end def method settings['REQUEST_METHOD'] end def post? settings['REQUEST_METHOD'] == 'POST' end def get? settings['REQUEST_METHOD'] == 'GET' end def query settings['QUERY_STRING'] || "" end def path settings['PATH_INFO'] end def data parse(rack_input) if post? end private def rack_input (settings['rack.input'].read).tap { settings['rack.input'].rewind } end def parse(json) begin JSON.parse(json) rescue JSON::ParserError => e logger.warn("Broker.environment#data: ParserError") nil end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alephant-broker-2.1.0 | lib/alephant/broker/environment.rb |
alephant-broker-2.0.3 | lib/alephant/broker/environment.rb |
alephant-broker-2.0.2 | lib/alephant/broker/environment.rb |