Class: Hanami::Routing::ForceSsl Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/routing/force_ssl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Force ssl

Redirect response to the secure equivalent resource (https)

Since:

  • 0.4.1

Constant Summary collapse

SSL_SCHEME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Https scheme

Since:

  • 0.4.1

'https'.freeze
HTTPS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'HTTPS'.freeze
ON =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'on'.freeze
LOCATION_HEADER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Location header

Since:

  • 0.4.1

'Location'.freeze
DEFAULT_HTTP_PORT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Default http port

Since:

  • 0.4.1

80
DEFAULT_SSL_PORT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Default ssl port

Since:

  • 0.4.1

443
MOVED_PERMANENTLY_HTTP_CODE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Moved Permanently http code

Since:

  • 0.4.1

301
TEMPORARY_REDIRECT_HTTP_CODE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Temporary Redirect http code

Since:

  • 0.4.1

307
HTTP_X_FORWARDED_SSL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'HTTP_X_FORWARDED_SSL'.freeze
HTTP_X_FORWARDED_SCHEME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'HTTP_X_FORWARDED_SCHEME'.freeze
HTTP_X_FORWARDED_PROTO =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'HTTP_X_FORWARDED_PROTO'.freeze
HTTP_X_FORWARDED_PROTO_SEPARATOR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

','.freeze
RACK_URL_SCHEME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'rack.url_scheme'.freeze
REQUEST_METHOD =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

'REQUEST_METHOD'.freeze
IDEMPOTENT_METHODS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

['GET', 'HEAD'].freeze
EMPTY_BODY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.1

[].freeze

Instance Method Summary collapse

Constructor Details

#initialize(active, options = {}) ⇒ ForceSsl

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize ForceSsl.

Parameters:

  • active (Boolean)

    activate redirection to SSL

  • options (Hash) (defaults to: {})

    set of options

Options Hash (options):

  • :host (String)
  • :port (Integer)

Since:

  • 0.4.1



96
97
98
99
100
101
102
# File 'lib/hanami/routing/force_ssl.rb', line 96

def initialize(active, options = {})
  @active = active
  @host   = options[:host]
  @port   = options[:port]

  _redefine_call
end

Instance Method Details

#call(env) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set 301 status and Location header if this feature is activated.

Parameters:

  • env (Hash)

    a Rack env instance

Returns:

  • (Array)

See Also:

  • HttpRouter#call

Since:

  • 0.4.1



114
115
# File 'lib/hanami/routing/force_ssl.rb', line 114

def call(env)
end

#force?(env) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if router has to force the response with ssl

Returns:

  • (Boolean)

Since:

  • 0.4.1



123
124
125
# File 'lib/hanami/routing/force_ssl.rb', line 123

def force?(env)
  !ssl?(env)
end