Skip to content

Commit

Permalink
Use services.AddPlugin to register plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Mar 23, 2024
1 parent b34fdb2 commit ce01b8a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
5 changes: 2 additions & 3 deletions MyApp/Configure.Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ namespace MyApp;
public class ConfigureAuth : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureAppHost(appHost =>
{
appHost.Plugins.Add(new AuthFeature(IdentityAuth.For<ApplicationUser>(options => {
.ConfigureServices(services => {
services.AddPlugin(new AuthFeature(IdentityAuth.For<ApplicationUser>(options => {
options.SessionFactory = () => new CustomUserSession();
options.CredentialsAuth();
options.AdminUsersFeature();
Expand Down
12 changes: 5 additions & 7 deletions MyApp/Configure.AutoQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ public void Configure(IWebHostBuilder builder) => builder
// Enable Audit History
services.AddSingleton<ICrudEvents>(c =>
new OrmLiteCrudEvents(c.GetRequiredService<IDbConnectionFactory>()));
})
.ConfigureAppHost(appHost => {

// For TodosService
appHost.Plugins.Add(new AutoQueryDataFeature());

services.AddPlugin(new AutoQueryDataFeature());
// For Bookings https://docs.servicestack.net/autoquery-crud-bookings
appHost.Plugins.Add(new AutoQueryFeature
{
services.AddPlugin(new AutoQueryFeature {
MaxLimit = 1000,
//IncludeTotal = true,
});

})
.ConfigureAppHost(appHost => {
appHost.Resolve<ICrudEvents>().InitSchema();
});
}
13 changes: 7 additions & 6 deletions MyApp/Configure.OpenApi.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
[assembly: HostingStartup(typeof(MyApp.ConfigureOpenApi))]
using MyApp.Data;

[assembly: HostingStartup(typeof(MyApp.ConfigureOpenApi))]

namespace MyApp;

public class ConfigureOpenApi : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((context, services) =>
{
.ConfigureServices((context, services) => {
if (context.HostingEnvironment.IsDevelopment())
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();

services.AddServiceStackSwagger();
services.AddBasicAuth<Data.ApplicationUser>();
services.AddBasicAuth<ApplicationUser>();
//services.AddJwtAuth();

services.AddTransient<IStartupFilter, StartupFilter>();
services.AddTransient<IStartupFilter,StartupFilter>();
}
});

Expand Down

0 comments on commit ce01b8a

Please sign in to comment.