File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
CoreHelpers.Branding.AspNet Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,39 @@ public static IApplicationBuilder UseBrandingWithRequestHost(this IApplicationBu
3333
3434 return app ;
3535 }
36+
37+ public static IApplicationBuilder UseBrandingOfferingRestEndpoint ( this IApplicationBuilder app , string endpoint )
38+ {
39+ app . Use ( async ( ctx , next ) =>
40+ {
41+ if ( ! ctx . Request . Path . HasValue || ! ctx . Request . Path . Value . ToLower ( ) . Equals ( endpoint . ToLower ( ) ) )
42+ {
43+
44+ // next middleware
45+ await next ( ctx ) ;
46+
47+ // done
48+ return ;
49+ }
50+
51+ // get the current branding
52+ var brandingStateService = ctx . RequestServices . GetRequiredService < IBrandingStateService > ( ) ;
53+ if ( brandingStateService == null )
54+ throw new Exception ( "BrandingStateService is not available" ) ;
55+
56+ // check if we have a current state
57+ if ( brandingStateService . CurrentCompanyBranding == null )
58+ throw new Exception ( "No branding state is available" ) ;
59+
60+ // write the branding as json
61+ await ctx . Response . WriteAsJsonAsync < ICompanyBranding > ( brandingStateService . CurrentCompanyBranding ) ;
62+
63+ // done
64+ return ;
65+ } ) ;
66+
67+ return app ;
68+ }
3669 }
3770}
3871
You can’t perform that action at this time.
0 commit comments