Sha256: 244759dc0bad4529451d00cab2eb5496a2104f21056ba31b7fb0021bab07914a
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
class Response # Abstract redirect response class Redirect < self include AbstractType # Build redirect response # # @param [String] location # the location to redirect to # # @return [Response::Redirect] # # @example # # # 302 response # response = Response::Redirect::Found.build('http://example.com') # response.status # => 302 # response.headers # => { "Location" => "http://example.com", "Content-Type" => "text/plain" } # response.body # => "You are beeing redirected to: http://example.com" # # # 301 response # response = Response::Redirect::Permanent.build('http://example.com') # response.status # => 301 # response.headers # => { "Location" => "http://example.com", "Content-Type" => "text/plain" } # response.body # => "You are beeing redirected to: http://example.com" # # # Overriding defaults # # response = Response::Redirect::Found.build('http://example.com') do |response| # response.with_body("Redirection") # end # # response[2] # => "Redirection" # # @api public # def self.build(location) super(self::STATUS, {'Location' => location, 'Content-Type' => TEXT_PLAIN}, "You are beeing redirected to: #{location}") end # Response with default status code of 302 class Found < self STATUS = Status::FOUND end # Response with default status code of 301 class Permanent < self STATUS = Status::MOVED_PERMANENTLY end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
response-0.0.4 | lib/response/redirect.rb |