Update to NetCore 3.1, added Kestrel for REST api and few basic endpoints.

This commit is contained in:
Karolis2011
2020-01-04 14:42:57 +02:00
parent 402d1943c1
commit 0e06afd5e6
8 changed files with 171 additions and 53 deletions

View File

@@ -0,0 +1,31 @@
using ASS.Server.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace ASS.Server.Web.Controllers
{
[ApiController]
[Route("[controller]")]
public class ByondController : ControllerBase
{
ByondService byondService;
public ByondController(ByondService bs)
{
byondService = bs;
}
[HttpPost("install/{major}.{minor}")]
public async Task<int> InstallVersionAsync(int major, int minor)
{
await byondService.SwitchToVersion(new API.ByondVersion() { Major = major, Minor = minor });
return 0;
}
}
}

View File

@@ -0,0 +1,34 @@
using ASS.Server.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
namespace ASS.Server.Web.Controllers
{
[ApiController]
[Route("[controller]")]
public class StatusController : ControllerBase
{
IServiceProvider serviceProvider;
public StatusController(IServiceProvider sp)
{
serviceProvider = sp;
}
[Route("")]
[Route("int")]
[HttpGet]
public IEnumerable<int> GetInt()
{
var rng = new Random();
var grpc = serviceProvider.GetRequiredService<GrpcService>();
if (!grpc.IsInitilized)
grpc.Initialize();
return new int[] { rng.Next() };
}
}
}

48
ASS.Server/Web/Startup.cs Normal file
View File

@@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
namespace ASS.Server.Web
{
class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
//app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}