Skip to content
Permalink
Browse files

Update README.md

  • Loading branch information...
neuecc committed May 15, 2019
1 parent 3a6aa3c commit ae4b85be1dfe8f232bce0d223462832be5e12d91
Showing with 30 additions and 23 deletions.
  1. +30 −23 README.md
@@ -611,30 +611,37 @@ MagicOnion has built-in Http1 JSON Gateway and [Swagger](http://swagger.io/) int
HttpGateway is built on ASP.NET Core. for example, with `Microsoft.AspNetCore.Server.WebListener`.
```csharp
static void Main(string[] args)
{
// setup MagicOnion hosting.
var magicOnionHost = MagicOnionHost.CreateDefaultBuilder()
.UseMagicOnion(
new MagicOnionOptions(isReturnExceptionStackTraceInErrorDetail: true),
new ServerPort("localhost", 12345, ServerCredentials.Insecure))
.UseConsoleLifetime()
.Build();
// NuGet: Microsoft.AspNetCore.Server.Kestrel
var webHost = new WebHostBuilder()
.ConfigureServices(collection =>
{
// Add MagicOnionServiceDefinition for reference from Startup.
collection.AddSingleton<MagicOnionServiceDefinition>(magicOnionHost.Services.GetService<MagicOnionServiceDefinition>());
})
.UseKestrel()
.UseStartup<Startup>()
.UseUrls("http://localhost:5432")
.Build();
// using MagicOnion.Hosting;
// using Microsoft.Extensions.DependencyInjection;
// using Microsoft.Extensions.Hosting;
// Run and wait both.
await Task.WhenAll(webHost.RunAsync(), magicOnionHost.RunAsync());
class Program
{
static async Task Main(string[] args)
{
// setup MagicOnion hosting.
var magicOnionHost = MagicOnionHost.CreateDefaultBuilder()
.UseMagicOnion(
new MagicOnionOptions(isReturnExceptionStackTraceInErrorDetail: true),
new ServerPort("localhost", 12345, ServerCredentials.Insecure))
.UseConsoleLifetime()
.Build();
// NuGet: Microsoft.AspNetCore.Server.Kestrel
var webHost = new WebHostBuilder()
.ConfigureServices(collection =>
{
// Add MagicOnionServiceDefinition for reference from Startup.
collection.AddSingleton<MagicOnionServiceDefinition>(magicOnionHost.Services.GetService<MagicOnionServiceDefinition>());
})
.UseKestrel()
.UseStartup<Startup>()
.UseUrls("http://localhost:5432")
.Build();
// Run and wait both.
await Task.WhenAll(webHost.RunAsync(), magicOnionHost.RunAsync());
}
}
// WebAPI Startup configuration.

0 comments on commit ae4b85b

Please sign in to comment.
You can’t perform that action at this time.