twilio-labs / twilio-aspnet

Integrate Twilio Programmable Messaging and Voice with ASP.NET Respond to webhooks with TwiML in seconds
Apache License 2.0
59 stars 30 forks source link

Add types for Minimal API #35

Closed Swimburger closed 2 years ago

Swimburger commented 2 years ago

ASP.NET Core 6 introduced a new way to build web applications using Minimal API. This doesn't use controllers or action results, but uses the new IResult type. It is suggested to add extension methods to IResultExtensions so it can be invoked using Results.Extensions.YourExtension. Here's the guidance I found: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-6.0#customizing-results

To get this to work, I had to make a couple of decisions which should be up for discussion:

This is how the new code would be used:

app.MapGet("/voice", () =>
{
    var response = new VoiceResponse();
    response.Say("Hello World!");
    return Results.Extensions.TwiML(response);
});
app.MapGet("/message", () =>
{
    var response = new MessagingResponse();
    response.Message("Hello World!");
    return Results.Extensions.TwiML(response);
});

What do y'all think?

Contributing to Twilio

All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.

Swimburger commented 2 years ago

Couple of updates:

Swimburger commented 2 years ago

@dprothero what are the next steps to get this towards a mergable state?

dprothero commented 2 years ago

@Swimburger I think it's there!

Swimburger commented 2 years ago

@dprothero this is ready for review, would you like to review it or should I ask someone else?