Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain Example #12

Open
Jxckaroo opened this issue Apr 12, 2023 · 1 comment
Open

Domain Example #12

Jxckaroo opened this issue Apr 12, 2023 · 1 comment

Comments

@Jxckaroo
Copy link

Hey 👋

Love the work!

Do you have an example of multi tenancy via domains with individual databases? For example:

Main domain: mysaasapp.com
Tenant domain: tenantname.mysaasapp.com
Tenant 2 domain tenanttwoname.mysaasapp.com

etc? From what I read, its supported, but unsure on implementation.

@goxiaoy
Copy link
Collaborator

goxiaoy commented Apr 13, 2023

change this line

saas/examples/gorm/main.go

Lines 136 to 137 in 0b157bc

r.Use(sgin.MultiTenancy(tenantStore))

to

import(
   ...
   shttp "github.com/go-saas/saas/http"
   ...
)
...
r.Use(sgin.MultiTenancy(tenantStore,
		sgin.WithMultiTenancyOption(shttp.NewWebMultiTenancyOption("", "([-a-z0-9]+)\\.mysaasapp\\.com"))))

adjust your own tenant name regex format

see https://github.com/go-saas/saas/blob/main/http/domain_tenant_resolve_contrib.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants