Skip to content

Instantly share code, notes, and snippets.

@telfaria
Last active October 15, 2023 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telfaria/1c4dd6a8451aa8d7b2da8fe276a47940 to your computer and use it in GitHub Desktop.
Save telfaria/1c4dd6a8451aa8d7b2da8fe276a47940 to your computer and use it in GitHub Desktop.
MagicOnion Server Startup
using MagicOnion;
using MagicOnion.Server;
using MagicOnionApp.Shared;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
namespace MagicOnionApp.Server
{
internal class Program
{
static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options =>
{
// WORKAROUND: Accept HTTP/2 only to allow insecure HTTP/2 connections during development.
options.ConfigureEndpointDefaults(endpointOptions =>
{
endpointOptions.Protocols = HttpProtocols.Http2;
});
});
builder.Services.AddGrpc(); // MagicOnion depends on ASP.NET Core gRPC service.
builder.Services.AddMagicOnion();
var app = builder.Build();
app.MapMagicOnionService();
app.Run();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment