Skip to content

Add extension methods to ControllerBase for TwiML #45

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

Merged
merged 1 commit into from
Mar 10, 2022

Conversation

Swimburger
Copy link
Contributor

This PR adds TwiML extension methods for ControllerBase to create a TwiMLResult.
This allows developers to use the TwiML methods without having to inherit from TwilioController.

A developer would use the extension method like this:

using Twilio.AspNet.Core;
using Twilio.TwiML;

public class SmsController : Controller
{
    public TwiMLResult Index()
    {
        var messagingResponse = new MessagingResponse();
        messagingResponse.Message("The Robots are coming! Head for the hills!!");

        return this.TwiML(messagingResponse);
    }
}

Note that the this keyword is required because it's an extension method.

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.

  • I acknowledge that all my contributions will be made under the project's license.

Copy link
Collaborator

@dprothero dprothero left a comment

Choose a reason for hiding this comment

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

LGTM!

@Swimburger Swimburger merged commit 6cb359f into twilio-labs:main Mar 10, 2022
@Swimburger Swimburger deleted the twiml-extension-methods branch March 10, 2022 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants