Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active February 7, 2024 06:21
Show Gist options
  • Save gistlyn/01197457ed250d88761890c851bcdbbf to your computer and use it in GitHub Desktop.
Save gistlyn/01197457ed250d88761890c851bcdbbf to your computer and use it in GitHub Desktop.
Configure gRPC
dotnet add package ServiceStack.Extensions
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