Initial commit of webservice host for the update server service.
This commit is contained in:
59
tononixPC.UpdateServer.Server/Program.cs
Executable file
59
tononixPC.UpdateServer.Server/Program.cs
Executable file
@@ -0,0 +1,59 @@
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Rewrite;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
|
||||
namespace tononixPC.UpdateServer.Server
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var host = WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Adds a default in-memory implementation of IDistributedCache.
|
||||
services.AddDistributedMemoryCache();
|
||||
|
||||
services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromMinutes(30);
|
||||
options.Cookie.HttpOnly = true;
|
||||
});
|
||||
|
||||
services.AddPhp(options =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseSession();
|
||||
// Make the server rewrite to update.php
|
||||
var options = new RewriteOptions()
|
||||
.AddRewrite(@"^(.*)$", "update.php/$1", skipRemainingRules: true);
|
||||
app.UseRewriter(options);
|
||||
app.UsePhp();
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user