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() };
}
}
}