コード例 #1
0
 protected void Application_Start(object sender, EventArgs e)
 {
     var appHost = new AppHost();
     appHost.Plugins.Add(new SessionFeature());
     appHost.Plugins.Add(new SwaggerFeature());
     #if DEBUG
     // Allow cross-site scripting for stand-alone development
     appHost.Plugins.Add(new CorsFeature(
         allowedMethods: "GET, POST, OPTIONS",
         allowedHeaders: "Origin, X-Requested-With, Content-Type, Accept, X-ApiKey, X-ss-pid, X-ss-opt"));
     #endif
     appHost.GlobalRequestFilters.Add(
         (req, res, dto) => {
             var localBypass = false;
     #if DEBUG
             localBypass = req.IsLocal;
     #endif
             if (localBypass) return;
             var attr = dto.GetType().GetCustomAttributes(typeof(AuthenticateAttribute), false);
             if (attr.Length <= 0) return;
             var apiKey = req.Headers["X-ApiKey"] ?? req.GetParam("X-ApiKey");
             if (apiKey == null || apiKey != ConfigurationManager.AppSettings["APIKey"])
             {
                 throw HttpError.Unauthorized("Unauthorized");
             }
         });
     typeof(Resources).AddAttributes(new RestrictAttribute { VisibilityTo = RequestAttributes.None });
     typeof(ResourceRequest).AddAttributes(new RestrictAttribute { VisibilityTo = RequestAttributes.None });
     appHost.Init();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: bowes282/ServiceStackVS
        static void Main()
        {
            Cef.Initialize(new CefSettings());

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            AppHost = new AppHost();
            AppHost.Init().Start("http://*:1337/");
            "ServiceStack SelfHost listening at {0} ".Fmt(HostUrl).Print();
            Form = new FormMain();
            Application.Run(Form);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: RemcovandenBerg/AppStack
        //Run it!
        static void Main(string[] args)
        {
            GlobalData.HostSettings = RetrieveSettings();

            var listeningOn = args.Length == 0 ? "http://*:8888/" : args[0];
            var appHost = new AppHost()
                .Init()
                .Start(listeningOn);

            Console.WriteLine("AppHost Created at {0}, listening on {1}",
                DateTime.Now, listeningOn);

            Console.ReadKey();
        }
コード例 #4
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void Main(string[] args)
        {
            var listeningOn = args.Length == 0 ? "http://*:1337/" : args[0];
            var appHost = new AppHost()
                            .Init()
                            .Start(listeningOn);

            Logger.LogMessage("AppHost Created at {0}, listening on {1}",
            DateTime.Now, listeningOn);

            Task.Factory.StartNew(SomerBlinkStateMachine.RunPromoCheck, TaskCreationOptions.LongRunning);

            Console.ReadLine();
            Console.Write("Preparing to cancel...");
            Console.ReadLine();
        }
コード例 #5
0
        static void Main(string[] args)
        {
            LogManager.LogFactory = new ConsoleLogFactory();

            var listeningOn = args.Length == 0 ? "http://*:8090/" : args[0];

            var appHost = new AppHost();

            appHost.Init();
            appHost.Start(listeningOn);

            Console.WriteLine("AppHost Created at {0}, listening on {1}",
                DateTime.Now, listeningOn);

            Console.ReadKey();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            var appHost = new AppHost();
            appHost.Init();
            appHost.Start(ListeningOn);

            Console.WriteLine("Started listening on: " + ListeningOn);

            Console.WriteLine("AppHost Created at {0}, listening on {1}",
                DateTime.Now, ListeningOn);


            Process.Start(ListeningOn);
            Console.WriteLine("ReadKey()");
            Console.ReadKey();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: tig2810/ServiceStackIssues
        static void Main(string[] args)
        {
            var app = new AppHost();
            app.Start();

            Process.Start(app.URL);

            //JsonServiceClient client = new JsonServiceClient(app.URL);
            //var response = client.Get<HttpWebResponse>("/json/reply/OrderRequestDto");

            /* ServiceStack */

            Console.WriteLine("Following tests are done using ServiceStack serializer");
            Console.WriteLine();

            Print("TEST: Buyer attached to each order:");
            SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=true");

            Console.WriteLine();

            Print("TEST: Buyer was not set to order (need assembler):");
            SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=false");

            /* JSON.NET */

            Console.WriteLine();
            Console.WriteLine("Following tests are done using JSON.NET serializer");
            Console.WriteLine();

            JsConfig<OrderResponseDto>.RawSerializeFn = t => JsonConvert.SerializeObject(t);
            JsConfig<OrderResponseDto>.RawDeserializeFn = t => JsonConvert.DeserializeObject<OrderResponseDto>(t);

            Print("TEST: Buyer attached to each order:");
            SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=true");

            Console.WriteLine();

            Print("TEST: Buyer was not set to order (need assembler):");
            SendRequest(app.URL + "json/reply/OrderRequestDto?AttachBuyerToOrder=false");

            "Press any key to exit...".Print();
            Console.ReadLine();
        }