Skip to content

Commit 21406ec

Browse files
committed
[r] project setup
[edit] switch to v2 controllers
1 parent f7db17a commit 21406ec

File tree

5 files changed

+29
-42
lines changed

5 files changed

+29
-42
lines changed

src/TestServer/Controllers/Api/v1/TestInController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace TestServer.Controllers.Api.v1;
1111

1212
[Post("/api/v1/testIn")]
13-
public class TestInController : AsyncController<MultipartViewModel>
13+
public class TestInController : Controller2<MultipartViewModel>
1414
{
15-
public override async Task<ControllerResponse> Invoke()
15+
public async Task<ControllerResponse> Invoke()
1616
{
1717
var file = Model.Files.FirstOrDefault() ?? throw new ArgumentException("No files in model");
1818
using var stream = new StreamReader(file.Data);

src/TestServer/Controllers/StatusController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace TestServer.Controllers;
55

66
[Get("status")]
7-
public class StatusController : Controller
7+
public class StatusController : Controller2
88
{
9-
public override ControllerResponse Invoke() => Content("Service is running!");
9+
public ControllerResponse Invoke() => Content("Service is running!");
1010
}

src/TestServer/Program.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
using Microsoft.AspNetCore;
2-
using Microsoft.AspNetCore.Hosting;
1+
using Microsoft.AspNetCore.Builder;
2+
using Simplify.DI;
3+
using Simplify.Web;
4+
using Simplify.Web.Model;
5+
using Simplify.Web.Multipart.Model.Binding;
6+
using TestServer.Setup;
37

4-
namespace TestServer;
8+
DIContainer.Current
9+
.RegisterAll()
10+
.Verify();
511

6-
public class Program
7-
{
8-
public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run();
12+
HttpModelHandler.RegisterModelBinder<HttpMultipartFormModelBinder>();
913

10-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
11-
WebHost.CreateDefaultBuilder(args)
12-
.UseStartup<Startup>();
13-
}
14+
var builder = WebApplication.CreateBuilder(args);
15+
16+
var app = builder.Build();
17+
18+
app.UseSimplifyWeb();
19+
20+
await app.RunAsync();
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
using Simplify.DI;
2+
using Simplify.Web;
23
using Simplify.Web.Multipart;
34

45
namespace TestServer.Setup;
56

67
public static class IocRegistrations
78
{
8-
public static void Register() => DIContainer.Current.RegisterHttpMultipartFormModelBinder();
9+
public static IDIContainerProvider RegisterAll(this IDIContainerProvider provider)
10+
{
11+
provider.RegisterHttpMultipartFormModelBinder()
12+
.RegisterSimplifyWeb();
13+
14+
return provider;
15+
}
916
}

src/TestServer/Startup.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)