source: Farmatiko/Startup.cs@ c352b2d

Last change on this file since c352b2d was 92a1f41, checked in by Mile Jankuloski <mile.jankuloski@…>, 4 years ago

Revert "Merge branch 'master' of https://develop.finki.ukim.mk/git/farmatiko"

This reverts commit 0c48bbb15c709978f24de20eba18e85b11b413f0, reversing
changes made to dba4ca99892de5ac575b5b732c6926c30f837f5f.

Reverting

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[30a465f]1using Microsoft.AspNetCore.Builder;
2using Microsoft.AspNetCore.Hosting;
[92a1f41]3using Microsoft.AspNetCore.HttpsPolicy;
[30a465f]4using Microsoft.AspNetCore.SpaServices.AngularCli;
5using Microsoft.Extensions.Configuration;
6using Microsoft.Extensions.DependencyInjection;
7using Microsoft.Extensions.Hosting;
8using FarmatikoData;
9using Microsoft.EntityFrameworkCore;
10
11namespace Farmatiko
12{
13 public class Startup
14 {
15 public Startup(IConfiguration configuration)
16 {
17 Configuration = configuration;
18 }
19
20 public IConfiguration Configuration { get; }
21
22 // This method gets called by the runtime. Use this method to add services to the container.
23 public void ConfigureServices(IServiceCollection services)
24 {
25 services.AddControllersWithViews();
26 // In production, the Angular files will be served from this directory
27 services.AddSpaStaticFiles(configuration =>
28 {
29 configuration.RootPath = "ClientApp/dist";
30 });
31 var connectionString = Configuration.GetSection("ConnectionStrings").GetValue<string>("FarmatikoConnection");
[92a1f41]32 services.AddEntityFrameworkNpgsql().AddDbContext<FarmatikoDataContext>(opt => opt.UseNpgsql(connectionString));
[30a465f]33
34 }
35
36 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
37 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
38 {
39 if (env.IsDevelopment())
40 {
41 app.UseDeveloperExceptionPage();
42 }
43 else
44 {
45 app.UseExceptionHandler("/Error");
46 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
47 app.UseHsts();
48 }
49
50 app.UseHttpsRedirection();
51 app.UseStaticFiles();
52 if (!env.IsDevelopment())
53 {
54 app.UseSpaStaticFiles();
55 }
56
57 app.UseRouting();
58
59 app.UseEndpoints(endpoints =>
60 {
61 endpoints.MapControllerRoute(
62 name: "default",
63 pattern: "{controller}/{action=Index}/{id?}");
64 });
65
66 app.UseSpa(spa =>
67 {
68 // To learn more about options for serving an Angular SPA from ASP.NET Core,
69 // see https://go.microsoft.com/fwlink/?linkid=864501
70
71 spa.Options.SourcePath = "ClientApp";
72
73 if (env.IsDevelopment())
74 {
75 spa.UseAngularCliServer(npmScript: "start");
76 }
77 });
78 }
79 }
80}
Note: See TracBrowser for help on using the repository browser.