Last active
February 7, 2024 06:21
-
-
Save gistlyn/01197457ed250d88761890c851bcdbbf to your computer and use it in GitHub Desktop.
Configure gRPC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet add package ServiceStack.Extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ServiceStack; | |
[assembly: HostingStartup(typeof(MyApp.ConfigureGrpc))] | |
namespace MyApp; | |
public class ConfigureGrpc : IHostingStartup | |
{ | |
public void Configure(IWebHostBuilder builder) => builder | |
.ConfigureServices(services => { | |
services.AddServiceStackGrpc(); | |
services.AddTransient<IStartupFilter,StartupFilter>(); | |
}) | |
.ConfigureAppHost(appHost => { | |
appHost.Plugins.Add(new GrpcFeature(appHost.GetApp())); | |
}); | |
public class StartupFilter : IStartupFilter | |
{ | |
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next) => app => | |
{ | |
app.UseRouting(); | |
next(app); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment