Created
July 15, 2020 15:29
-
-
Save MufidJamaluddin/470b656799495159a083ea9cfed15f3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace IssueTracker | |
{ | |
public class Startup | |
{ | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IssueTrackerDbContext dbContext, ILoggerFactory loggerFactory) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
dbContext?.Database.Migrate(); | |
SeedRunner.Run(dbContext); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Error"); | |
app.UseHsts(); | |
} | |
// Middleware Yang Wajibin HTTPS | |
if (appConfig.UseHttps) | |
{ | |
app.UseHttpsRedirection(); | |
} | |
// Middleware Buat Handle Permintaan Static File | |
app.UseStaticFiles(); | |
// Middleware Buat Handle Permintaan Static File SPA (AngularJS, ReactJS, VueJS, dsb) | |
app.UseSpaStaticFiles(); | |
// Middleware Buat Routing Aplikasi | |
app.UseRouting(); | |
// Custom Middleware Dapetin JWT dari Cookie | |
app.UseJwtInCookie(); | |
// Middleware Otentikasi (Login) | |
app.UseAuthentication(); | |
// Middleare Otorisasi (Role Login) | |
app.UseAuthorization(); | |
// Mapping Permintaan URL dengan Controller | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapControllerRoute( | |
name: "default", | |
pattern: "{controller}/{action=Index}/{id?}"); | |
}); | |
// Pakai URL SPA | |
app.UseSpa(spa => | |
{ | |
spa.Options.SourcePath = "ClientApp"; | |
if (env.IsDevelopment()) | |
{ | |
spa.UseReactDevelopmentServer(npmScript: "start"); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment