public static void Main(string[] args) { string codeBase = Assembly.GetExecutingAssembly().CodeBase; string name = Path.GetFileName(codeBase); string secretToken = String.Empty; if (args.Length == 0) { Console.WriteLine ("Usage: " + name + " <secret token>"); Environment.Exit (0); } else { secretToken = args [0]; } StaticConfiguration.DisableErrorTraces = false; StaticConfiguration.EnableHeadRouting = true; var uri = "http://localhost:8888"; var urlReservations = new UrlReservations(); urlReservations.CreateAutomatically = true; var settings = new DefaultWebhookSettings (secretToken); var hostConfiguration = new HostConfiguration(); hostConfiguration.UrlReservations = urlReservations; // initialize an instance of NancyHost var host = new NancyHost (new Uri(uri), new CustomBootstrapper(settings), hostConfiguration); host.Start(); // start hosting Console.WriteLine("Started " + name + " on " + uri + " with secret token " + secretToken); Console.WriteLine (); Console.WriteLine ("Upon each wehook event, this program will post back a OK or No Match response after analyzing message hash."); Console.WriteLine ("Also make sure " + uri + "/exzeo_events is used as a callback url in your webhook registration" ); // check if we're running on mono if (Type.GetType ("Mono.Runtime") != null) { // on mono, processes will usually run as daemons - this allows you to listen // for termination signals (ctrl+c, shutdown, etc) and finalize correctly UnixSignal.WaitAny (new[] { new UnixSignal (Signum.SIGINT), new UnixSignal (Signum.SIGTERM), new UnixSignal (Signum.SIGQUIT), new UnixSignal (Signum.SIGHUP) }); } else { Console.ReadLine (); } Console.WriteLine ("Stopping " + name + " application"); host.Stop (); // stop hosting }
public CustomBootstrapper(DefaultWebhookSettings impl) { this.instance = impl; }