Commit 857d9e30 authored by Uta Christoph's avatar Uta Christoph
Browse files

Merge branch 'feature/internal-routing' into 'master'

Feature/internal routing into master

See merge request !16
parents bd4e927b 7060d9fa
Pipeline #434687 passed with stages
in 1 minute and 50 seconds
......@@ -4,7 +4,7 @@ job "pdf-generator" {
type = "system"
update {
stagger = "60s"
stagger = "60s"
max_parallel = 1
}
......@@ -25,8 +25,8 @@ job "pdf-generator" {
#
# You may want this to be full paths to your local repo build on dev
args = [
"C:\\Users\\userid\\Source\\Repos\\pdf-generator\\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\\pdf-generator.dll",
"PATH_TO_PDF-GENERATOR_MICROSERVICE\\pdf-generator\\bin\\Debug\\netcoreapp3.1\\appsettings.json"
]
}
......@@ -43,6 +43,7 @@ job "pdf-generator" {
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.routers.pdfgenerator.entrypoints=internal",
"traefik.Path=/${NOMAD_TASK_NAME}"
]
......@@ -57,7 +58,7 @@ job "pdf-generator" {
resources {
network {
port "http" {
port "http" {
}
}
}
......
......@@ -4,7 +4,7 @@ job "pdf-generator" {
type = "system"
update {
stagger = "60s"
stagger = "60s"
max_parallel = 1
}
......@@ -33,7 +33,7 @@ job "pdf-generator" {
ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}",
# Pass the basedir used by Traefik to the app
ASPNETCORE_BASEPATH = "/internal/${NOMAD_TASK_NAME}"
ASPNETCORE_BASEPATH = "/${NOMAD_TASK_NAME}"
}
service {
......@@ -41,7 +41,8 @@ job "pdf-generator" {
port = "http"
tags = [
"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
......
......@@ -4,7 +4,7 @@ job "pdf-generator-testing" {
type = "system"
update {
stagger = "60s"
stagger = "60s"
max_parallel = 1
}
......@@ -33,7 +33,7 @@ job "pdf-generator-testing" {
ASPNETCORE_URLS = "http://*:${NOMAD_PORT_http}",
# Pass the basedir used by Traefik to the app
ASPNETCORE_BASEPATH = "/internal/${NOMAD_TASK_NAME}"
ASPNETCORE_BASEPATH = "/${NOMAD_TASK_NAME}"
}
service {
......@@ -41,7 +41,8 @@ job "pdf-generator-testing" {
port = "http"
tags = [
"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
......
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;
......@@ -31,7 +32,7 @@ namespace PDFGenerator
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
IHostBuilder builder = Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
......@@ -41,6 +42,16 @@ namespace PDFGenerator
logging.SetMinimumLevel(LogLevel.Trace);
})
.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
{
public const string API_TITLE = "PDFGenerator API";
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)
{
......@@ -61,12 +61,8 @@ namespace PDFGenerator
app.UseCors(options => options.AllowAnyOrigin());
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
......@@ -77,8 +73,8 @@ namespace PDFGenerator
app.UseSwaggerUI(c =>
{
// the Swagger file also needs the correct basePath set here
string swaggerUrl = basePath != "/" ? basePath + API_ENDPOINT : API_ENDPOINT;
c.SwaggerEndpoint(swaggerUrl, API_TITLE + ' ' + API_VERSION);
string swaggerUrl = API_ENDPOINT;
c.SwaggerEndpoint(swaggerUrl, $"{API_TITLE} {API_VERSION}");
});
}
}
......
Markdown is supported
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