Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrSubdomainDoesNotMatchRegex = errors.New("subdomain does not match regex")
)
Functions ¶
func Subdomain ¶
func Subdomain(externalURL string, backendRepo SubdomainBackendRepo, redisClient *common.RedisClient) echo.MiddlewareFunc
Subdomain is middleware that routes requests based on the subdomain format.
It extracts either a deployment's subdomain or a stub ID from the request's host. Based on the extracted value, it fetches the corresponding deployment or stub, builds the appropriate handler path, and invokes the corresponding handler.
Supported Subdomain Formats: - {subdomain}.app.example.com // Routes to the "latest" version of a deployment - {subdomain}-latest.app.example.com // Routes to the "latest" version of a deployment - {subdomain}-v{version}.app.example.com // Routes to a specific version of a deployment - {stubId}.app.example.com // Routes to a specified stub, typically used for serves
Types ¶
type SubdomainBackendRepo ¶
type SubdomainBackendRepo interface { GetStubByExternalId(ctx context.Context, externalId string, queryFilters ...types.QueryFilter) (*types.StubWithRelated, error) GetDeploymentBySubdomain(ctx context.Context, subdomain string, version uint) (*types.DeploymentWithRelated, error) }