Ragnarok.HostedService
2.0.0
dotnet add package Ragnarok.HostedService --version 2.0.0
NuGet\Install-Package Ragnarok.HostedService -Version 2.0.0
<PackageReference Include="Ragnarok.HostedService" Version="2.0.0" />
paket add Ragnarok.HostedService --version 2.0.0
#r "nuget: Ragnarok.HostedService, 2.0.0"
// Install Ragnarok.HostedService as a Cake Addin #addin nuget:?package=Ragnarok.HostedService&version=2.0.0 // Install Ragnarok.HostedService as a Cake Tool #tool nuget:?package=Ragnarok.HostedService&version=2.0.0
<div align="center"> <h1> Ragnarok </h1> </div>
Ragnarok.HostedService
By adding the NgrokHostedService
to your application, ngrok tunnels will be automatically created for any local application URLs.
Installation
Install via Nuget
Usage
UseNgrok Extension
An extension method is provided on the IWebHostBuilder
to setup the NgrokHostedService
.
Optional parameters are available that allow for defining a tunnel
as well as options for managing the bahavior of the RagnarokClient
.
The option to automatically download ngrok is disabled by default. It can be enabled via the options parameter.
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(x => x
.UseStartup<Startup>()
.UseNgrok(options => options.DownloadNgrok = true,
tunnel => tunnel.WithName("weather-api")
.WithOauthProvider("google")
.WithDomain("cheerful-sober-mudfish.ngrok-free.app"));
Behind the scenes
On application startup, all registered server addresses are retrieved, and an ngrok
client is started (if necessary). Tunnels are then dynamically created for each server address.
The public url
for the created tunnels can be retrieved via the ngrok Agent Api
, by subscribing to the Ready
event of the hosted service, or subscribing to the TunnelCreated
event of the RagnarokClient
.
If not tunnels are defined in the yml config file, you can define a tunnel using the hosted service (as shown above) or a default tunnel will be automatically created.
Ngrok Agent Api
The NgrokHostedService
is added to the applications ServiceCollection
, allowing for access via Dependency Injection
. It provides full access to the ngrok Agent Api via the RagnarokClient
property.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.0)
- Ragnarok.AgentApi (>= 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Update to .Net 8 and Ngrok v3