Sha256: a1f5d4d8a60b724ee2d8e31bba36cada6a6c951b03e1693324f038e7b345cc9d
Contents?: true
Size: 1007 Bytes
Versions: 2
Compression:
Stored size: 1007 Bytes
Contents
# frozen_string_literal: true require 'rack' module ProxES class Request < Rack::Request def self.from_env(env) request = Rack::Request.new(env) splits = request.path.split('/') endpoint = if splits[1] && splits[1][0] == '_' splits[1][1..-1].titlecase else splits.count > 0 ? splits[-1][1..-1].titlecase : 'Root' end begin require 'proxes/request/' + endpoint.downcase ProxES::Request.const_get(endpoint).new(env) rescue LoadError self.new(env) end end def initialize(env) super parse end def endpoint path_parts[0] end def parse path_parts end def indices? false end private def path_parts @path_parts ||= path[1..-1].split('/') end def check_part(val) return val if val.nil? return [] if [endpoint, '_all'].include? val val.split(',') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
proxes-0.2.0 | lib/proxes/request.rb |
proxes-0.1.0 | lib/proxes/request.rb |