Esempio n. 1
0
 /// <summary>
 /// Adds a piece of middleware to handle Inbound SMS messages. Will return a 204 if it encounters a valid sms, 401 if it can't authenticate the SMS, and a 500 if anything else goes wrong
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="handler">Delegate to handle the inbound SMS</param>
 /// <param name="path">the route you'd like to handle the inbound SMS over, this should correspond to what you've set in the vonage dashboard</param>
 /// <param name="signatureSecret">The signature secret to validate the SMS Against, defaults to null, if this is not set the SMS will not be validated</param>
 /// <param name="method">Signature method to use for validating SMS messages</param>
 /// <param name="invokeNextMiddleware">Whetehr to invoke the next piece of middleware in your pipeline, if this is false this middleware will exit immediately after completing</param>
 /// <returns></returns>
 public static IApplicationBuilder UseVonageSms(this IApplicationBuilder builder,
                                                InboundSmsDelegate handler,
                                                string path            = "/webhooks/inbound-sms",
                                                string signatureSecret = null,
                                                SmsSignatureGenerator.Method method = SmsSignatureGenerator.Method.md5hash,
                                                bool invokeNextMiddleware           = false)
 {
     return(builder.Map(path, b => b.UseMiddleware <InboundSmsWebhookHandler>(handler, signatureSecret, method, invokeNextMiddleware)));
 }
Esempio n. 2
0
 internal InboundSmsWebhookHandler(RequestDelegate next,
                                   InboundSmsDelegate handler,
                                   string signatureSecret = null,
                                   SmsSignatureGenerator.Method method = SmsSignatureGenerator.Method.md5hash,
                                   bool invokeNext = false)
 {
     _delegate             = handler;
     _next                 = next;
     _signatureSecret      = signatureSecret;
     _signatureMethod      = method;
     _invokeNextMiddleware = invokeNext;
 }