Last active
October 15, 2023 10:13
-
-
Save telfaria/1c4dd6a8451aa8d7b2da8fe276a47940 to your computer and use it in GitHub Desktop.
MagicOnion Server Startup
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 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