Sha256: c3262385fb19628470849c64252c64d501dbd65c60f191759df294e05066bddf

Contents?: true

Size: 576 Bytes

Versions: 8

Compression:

Stored size: 576 Bytes

Contents

module Hippo
    module API
        class TenantDomainRouter
            def initialize(app)
                @app = app
            end

            def call(env)
                domain_parts = env['SERVER_NAME'].split('.')
                if domain_parts.length == 3
                    tenant = Hippo::Tenant.where(slug: domain_parts.first).first
                    MultiTenant.with(tenant) do
                        @app.call(env)
                    end
                else
                    @app.call(env)
                end
            end
        end
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hippo-fw-0.9.9 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.8 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.7 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.6 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.5 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.4 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.3 lib/hippo/api/tenant_domain_router.rb
hippo-fw-0.9.2 lib/hippo/api/tenant_domain_router.rb