Commit 7060d9fa authored by Julia Dürselen's avatar Julia Dürselen 🚒 Committed by Uta Christoph
Browse files

Feature/internal routing into master

parent bd4e927b
...@@ -4,7 +4,7 @@ job "pdf-generator" { ...@@ -4,7 +4,7 @@ job "pdf-generator" {
type = "system" type = "system"
update { update {
stagger = "60s" stagger = "60s"
max_parallel = 1 max_parallel = 1
} }
...@@ -25,8 +25,8 @@ job "pdf-generator" { ...@@ -25,8 +25,8 @@ job "pdf-generator" {
# #
# You may want this to be full paths to your local repo build on dev # You may want this to be full paths to your local repo build on dev
args = [ args = [
"C:\\Users\\userid\\Source\\Repos\\pdf-generator\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\pdf-generator.dll", "PATH_TO_PDF-GENERATOR_MICROSERVICE\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\pdf-generator.dll",
"C:\\Users\\userid\\Source\\Repos\\pdf-generator\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\appsettings.Development.json" "PATH_TO_PDF-GENERATOR_MICROSERVICE\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\appsettings.json"
] ]
} }
...@@ -43,6 +43,7 @@ job "pdf-generator" { ...@@ -43,6 +43,7 @@ job "pdf-generator" {
port = "http" port = "http"
tags = [ tags = [
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers.pdfgenerator.entrypoints=internal",
"traefik.Path=/${NOMAD_TASK_NAME}" "traefik.Path=/${NOMAD_TASK_NAME}"
] ]
...@@ -57,7 +58,7 @@ job "pdf-generator" { ...@@ -57,7 +58,7 @@ job "pdf-generator" {
resources { resources {
network { network {
port "http" { port "http" {
} }
} }
} }
......
...@@ -4,7 +4,7 @@ job "pdf-generator" { ...@@ -4,7 +4,7 @@ job "pdf-generator" {
type = "system" type = "system"
update { update {
stagger = "60s" stagger = "60s"
max_parallel = 1 max_parallel = 1
} }
...@@ -33,7 +33,7 @@ job "pdf-generator" { ...@@ -33,7 +33,7 @@ job "pdf-generator" {
ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}", ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}",
# Pass the basedir used by Traefik to the app # Pass the basedir used by Traefik to the app
ASPNETCORE_BASEPATH = "/internal/${NOMAD_TASK_NAME}" ASPNETCORE_BASEPATH = "/${NOMAD_TASK_NAME}"
} }
service { service {
...@@ -41,7 +41,8 @@ job "pdf-generator" { ...@@ -41,7 +41,8 @@ job "pdf-generator" {
port = "http" port = "http"
tags = [ tags = [
"traefik.enable=true", "traefik.enable=true",
"traefik.Path=/internal/${NOMAD_TASK_NAME}" "traefik.http.routers.pdflive.entrypoints=internal",
"traefik.Path=/${NOMAD_TASK_NAME}"
] ]
# The check URL needs to answer with status 200, preferbly use something like a version API call # The check URL needs to answer with status 200, preferbly use something like a version API call
......
...@@ -4,7 +4,7 @@ job "pdf-generator-testing" { ...@@ -4,7 +4,7 @@ job "pdf-generator-testing" {
type = "system" type = "system"
update { update {
stagger = "60s" stagger = "60s"
max_parallel = 1 max_parallel = 1
} }
...@@ -33,7 +33,7 @@ job "pdf-generator-testing" { ...@@ -33,7 +33,7 @@ job "pdf-generator-testing" {
ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}", ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}",
# Pass the basedir used by Traefik to the app # Pass the basedir used by Traefik to the app
ASPNETCORE_BASEPATH = "/internal/${NOMAD_TASK_NAME}" ASPNETCORE_BASEPATH = "/${NOMAD_TASK_NAME}"
} }
service { service {
...@@ -41,7 +41,8 @@ job "pdf-generator-testing" { ...@@ -41,7 +41,8 @@ job "pdf-generator-testing" {
port = "http" port = "http"
tags = [ tags = [
"traefik.enable=true", "traefik.enable=true",
"traefik.Path=/internal/${NOMAD_TASK_NAME}" "traefik.http.routers.pdftesting.entrypoints=internal",
"traefik.Path=/${NOMAD_TASK_NAME}"
] ]
# The check URL needs to answer with status 200, preferbly use something like a version API call # The check URL needs to answer with status 200, preferbly use something like a version API call
......
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Web; using NLog.Web;
...@@ -31,7 +32,7 @@ namespace PDFGenerator ...@@ -31,7 +32,7 @@ namespace PDFGenerator
public static IHostBuilder CreateHostBuilder(string[] args) public static IHostBuilder CreateHostBuilder(string[] args)
{ {
return Host.CreateDefaultBuilder(args) IHostBuilder builder = Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
webBuilder.UseStartup<Startup>(); webBuilder.UseStartup<Startup>();
...@@ -41,6 +42,16 @@ namespace PDFGenerator ...@@ -41,6 +42,16 @@ namespace PDFGenerator
logging.SetMinimumLevel(LogLevel.Trace); logging.SetMinimumLevel(LogLevel.Trace);
}) })
.UseNLog(); // NLog: Setup NLog for Dependency injection .UseNLog(); // NLog: Setup NLog for Dependency injection
if (args.Length > 0)
{
builder.ConfigureAppConfiguration(builder =>
{
builder.AddJsonFile(args[0]);
});
}
return builder;
} }
} }
} }
...@@ -13,7 +13,7 @@ namespace PDFGenerator ...@@ -13,7 +13,7 @@ namespace PDFGenerator
{ {
public const string API_TITLE = "PDFGenerator API"; public const string API_TITLE = "PDFGenerator API";
public const string API_VERSION = "v1"; public const string API_VERSION = "v1";
public const string API_ENDPOINT = "/swagger/v1/swagger.json"; public const string API_ENDPOINT = "v1/swagger.json";
public Startup(IConfiguration configuration) public Startup(IConfiguration configuration)
{ {
...@@ -61,12 +61,8 @@ namespace PDFGenerator ...@@ -61,12 +61,8 @@ namespace PDFGenerator
app.UseCors(options => options.AllowAnyOrigin()); app.UseCors(options => options.AllowAnyOrigin());
app.UseHttpsRedirection();
app.UseRouting(); app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapControllers(); endpoints.MapControllers();
...@@ -77,8 +73,8 @@ namespace PDFGenerator ...@@ -77,8 +73,8 @@ namespace PDFGenerator
app.UseSwaggerUI(c => app.UseSwaggerUI(c =>
{ {
// the Swagger file also needs the correct basePath set here // the Swagger file also needs the correct basePath set here
string swaggerUrl = basePath != "/" ? basePath + API_ENDPOINT : API_ENDPOINT; string swaggerUrl = API_ENDPOINT;
c.SwaggerEndpoint(swaggerUrl, API_TITLE + ' ' + API_VERSION); c.SwaggerEndpoint(swaggerUrl, $"{API_TITLE} {API_VERSION}");
}); });
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment