Class: SocialAvatarProxy::App
- Inherits:
-
Object
- Object
- SocialAvatarProxy::App
- Defined in:
- lib/social_avatar_proxy/app.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/social_avatar_proxy/app.rb', line 20 def @options end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
20 21 22 |
# File 'lib/social_avatar_proxy/app.rb', line 20 def request @request end |
Class Method Details
.call(env) ⇒ Object
12 13 14 |
# File 'lib/social_avatar_proxy/app.rb', line 12 def self.call(env) new.call(env) end |
.routes ⇒ Object
16 17 18 |
# File 'lib/social_avatar_proxy/app.rb', line 16 def self.routes new.routes end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/social_avatar_proxy/app.rb', line 22 def call(env) @request = Rack::Request.new(env) begin response.finish rescue TimeoutError => e timeout rescue TooManyRedirectsError => e bad_gateway end end |
#path_prefix ⇒ Object
33 34 35 |
# File 'lib/social_avatar_proxy/app.rb', line 33 def path_prefix ((request && request.env["SCRIPT_NAME"]) || "").gsub(/\/$/, "") end |
#response ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/social_avatar_proxy/app.rb', line 37 def response # ensure this is a valid avatar request unless request.path =~ /^#{path_prefix}\/(facebook|twitter)\/([\w\-\.]+)(\.(jpe?g|png|gif|bmp))?$/i return not_found end # create our response SocialAvatarProxy::Response.build({ service: $1, identifier: $2 }) end |