Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 223x 223x 223x 223x 223x 17x 17x 17x 17x 1x 1x 16x | import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { FeatureToggleService } from 'ish-core/feature-toggle.module';
import { HttpStatusCodeService } from 'ish-core/utils/http-status-code/http-status-code.service';
/**
* Routes only to the page if the configured feature toggle at the route is switched on
*/
export function featureToggleGuard(route: ActivatedRouteSnapshot) {
const featureToggleService = inject(FeatureToggleService);
const router = inject(Router);
const httpStatusCodeService = inject(HttpStatusCodeService);
if (!featureToggleService.enabled(route.data.feature)) {
httpStatusCodeService.setStatus(404, false);
return router.createUrlTree(['/error'], {
queryParams: {
error: 'feature-deactivated',
value: route.data.feature,
},
});
}
return true;
}
|