Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update example to .NET 8 #7

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The usual requirements that Twitch has for EventSub webhooks do still apply!

## Setup

Step 1: Create a new ASP.NET Core project (.NET 5.0 and up)
Step 1: Create a new ASP.NET Core project (.NET 6.0 and up)

Step 2: Install the TwitchLib.EventSub.Webhooks nuget package. (See above on how to do that)

Expand All @@ -54,7 +54,8 @@ public void ConfigureServices(IServiceCollection services)
}
```

!!! If you follow these steps your callback url will https://{your_domain}/webhooks !!!
!!! If you follow these steps your callback url will `https://{your_domain}/webhooks`!!!
(The location of where to put this and the naming of variables might differ depending on what kind of project and general setup you have)

Step 4: Put the TwitchLib.EventSub.Webhooks middleware in the request pipeline

Expand All @@ -78,6 +79,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
});
}
```
(The location of where to put this and the naming of variables might differ depending on what kind of project and general setup you have)

Step 5: Create the HostedService and listen for events

Expand Down
45 changes: 29 additions & 16 deletions TwitchLib.EventSub.Webhooks.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using TwitchLib.EventSub.Webhooks.Example;
using TwitchLib.EventSub.Webhooks.Extensions;

namespace TwitchLib.EventSub.Webhooks.Example
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllers();
Copy link
Author

@AoshiW AoshiW May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: maybe we should remove everything related to controllers because they are not needed

builder.Services.AddTwitchLibEventSubWebhooks(config =>
{
config.CallbackPath = "/webhooks";
config.Secret = "supersecuresecret";
});
builder.Services.AddHostedService<EventSubHostedService>();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
app.UseDeveloperExceptionPage();
}

app.UseRouting();
app.UseAuthorization();

app.UseTwitchLibEventSubWebhooks();

app.MapControllers();

app.Run();
50 changes: 0 additions & 50 deletions TwitchLib.EventSub.Webhooks.Example/Startup.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down