module Lucky::Subdomain

Included Modules

Defined in:

lucky/subdomain.cr

Constant Summary

HABITAT_SETTINGS = [{decl: tld_length : Int32 = 1, example: nil, validation: nil}] of Nil
IP_HOST_REGEXP = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/

Taken from https://github.com/rails/rails/blob/afc6abb674b51717dac39ea4d9e2252d7e40d060/actionpack/lib/action_dispatch/http/url.rb#L8

Class Method Summary

Macro Summary

Instance Method Summary

Class Method Detail

def self.configure(&) #

[View source]
def self.settings #

[View source]

Macro Detail

macro require_subdomain(matcher = true) #

Sets up a subdomain requirement for an action

require_subdomain                                    # subdomain required but can be anything
require_subdomain "admin"                            # subdomain required and must equal "admin"
require_subdomain /(dev|qa|prod)/                    # subdomain required and must match regex
require_subdomain ["tenant1", "tenant2", /tenant\d/] # subdomain required and must match one of the items in the array

The subdomain can then be accessed from within the route block by calling subdomain.

If you don't want to require a subdomain but still want to check if one is passed you can still call subdomain? without using require_subdomain. Just know that subdomain? is nilable.


[View source]

Instance Method Detail

def settings #

[View source]