Example #1
0
        public void Configuration(IAppBuilder app)
        {
            //app.Use(async(enviornment, next) =>
            //{
            //    foreach (var Pair in enviornment.Environment)
            //    {
            //        Console.WriteLine("{0}:{1}", Pair.Key, Pair.Value);
            //    }
            //    await next();
            //});

            app.Use(async(enviornment, next) =>
            {
                Console.WriteLine("Requesting :" + enviornment.Request.Path);

                await next();

                Console.WriteLine("Response :" + enviornment.Response.StatusCode);
            });

            ConfigureWebApi(app);

            app.UseHelloWorld();
            //app.UseWelcomePage();
            //app.Run(ctx =>
            //{
            //    return ctx.Response.WriteAsync("Hello World!");
            //});
        }
Example #2
0
        public void Configuration(IAppBuilder app)
        {
            this.ConfigureWebApi(app);

            //app.Use(async (env, next) =>
            //{
            //    foreach (var pair in env.Environment)
            //    {
            //        Console.WriteLine("{0}: {1}", pair.Key, pair.Value.ToString());
            //    }

            //    await next();
            //});


            app.Use(async (env, next) =>
            {
                Console.WriteLine("Requesting: " + env.Request.Path);
                await next();
                Console.WriteLine("Response: " + env.Response.StatusCode);
                Console.WriteLine("---------------------");
            });

            app.UseHelloWorld();
        }
Example #3
0
        public void Configuration(IAppBuilder app)
        {
            //app.Use(async (environment, next) =>
            //{
            //    foreach (var pair in environment.Environment)
            //    {
            //        Console.WriteLine("{0} : {1}", pair.Key, pair.Value);
            //    }
            //    await next();
            //});

            //app.Use(async (environment, next) =>
            //{
            //    Console.WriteLine("Requesting : {0}", environment.Request.Path);
            //    await next();
            //    Console.WriteLine("Response : {0}", environment.Response.StatusCode);
            //});

            ConfigureWebApi(app);

            app.UseHelloWorld();

            //app.Run(ctx =>
            //{
            //    return ctx.Response.WriteAsync("Test");
            //});
            //app.Use<HelloWorldComponent>();
        }
Example #4
0
        public void Configuration(IAppBuilder app)
        {
            this.ConfigureWebApi(app);

            //app.Use(async (env, next) =>
            //{
            //    foreach (var pair in env.Environment)
            //    {
            //        Console.WriteLine("{0}: {1}", pair.Key, pair.Value.ToString());
            //    }

            //    await next();
            //});


            app.Use(async(env, next) =>
            {
                Console.WriteLine("Requesting: " + env.Request.Path);
                await next();
                Console.WriteLine("Response: " + env.Response.StatusCode);
                Console.WriteLine("---------------------");
            });

            app.UseHelloWorld();
        }
        public void Configuration(IAppBuilder app)
        {
//            app.Use(async (environment, next) =>
//            {
//                foreach (var pair in environment.Environment)
//                {
//                    Console.WriteLine($"{pair.Key}: {pair.Value}");
//                }
//
//                await next();
//            });

            app.Use(async(environment, next) =>
            {
                Console.WriteLine($"Requesting : {environment.Request.Path}");
                await next();
                Console.WriteLine($"Response : {environment.Response.StatusCode}");
            });

            ConfigureWebApi(app);
            app.UseHelloWorld();

//            app.Use<HelloWorldComponent>();

            //            app.UseWelcomePage();

            //            app.Run(ctx =>
            //            {
            //                return ctx.Response.WriteAsync("Hello World!");
            //            });
        }
Example #6
0
        public void Configuration(IAppBuilder app)
        {
            //app.Use(async (env, next) =>
            //{
            //    foreach (var pair in env.Environment)
            //    {
            //        Console.WriteLine($"{pair.Key} : {pair.Value}");
            //    }

            //    await next();
            //});

            app.Use(async(env, next) =>

            {
                Console.WriteLine($"Requesting: {env.Request.Path}");
                await next();

                Console.WriteLine($"Response: {env.Response.StatusCode}");
            });

            ConfigureWebApi(app);

            app.UseHelloWorld();
        }
Example #7
0
        public void Configuration(IAppBuilder app)
        {
            //app.Run(ctx =>
            //{
            //    return ctx.Response.WriteAsync("Hello World!");
            //});

            app.Use(async(environment, next) =>
            {
                foreach (var pair in environment.Environment)
                {
                    Console.WriteLine("{0}:{1}", pair.Key, pair.Value);
                }

                await next();
            });

            app.Use(async(environment, next) =>
            {
                Console.WriteLine("Request Path: " + environment.Request.Path);
                await next();
                Console.WriteLine("Response Code: " + environment.Response.StatusCode);
            });

            ConfigureWebApi(app);

            app.UseHelloWorld(); //Will use this middleware as a default if the WebApi doesn't handle a given request
        }
Example #8
0
 public void Configuration(IAppBuilder app)
 {
     app.UseHelloWorld(new HelloWorldOptions
     {
         IncludeTimestamp = true,
         Name             = "Earth"
     });
 }
Example #9
0
 public void Configuration(IAppBuilder app)
 {
     app.UseHelloWorld(new HelloWorldOptions
     {
         IncludeTimestamp = true,
         Name = "Earth"
     });
 }
Example #10
0
 public void Configuration(IAppBuilder app)
 {
     app.Use(async(environment, next) =>
     {
         Console.WriteLine("Requesting : " + environment.Request.Path);
         await next();
         Console.WriteLine("Response: " + environment.Response.StatusCode);
     });
     ConfigurationWebApi(app);
     app.UseHelloWorld();
 }
Example #11
0
        public void Configuration(IAppBuilder app)
        {
            app.Use(async(env, next) =>
            {
                Console.WriteLine($"Requesting: {env.Request.Path}");
                await next();
                Console.WriteLine($"Response: {env.Response.StatusCode}");
            });

            ConfigureWebApi(app);
            app.UseHelloWorld();
        }
Example #12
0
        public void Configuration(IAppBuilder app)
        {
            app.Use(async (environment, next) => {
                Console.WriteLine("Requesting : {0} ", environment.Request.Path); // request
                await next();
                Console.WriteLine("Response: " + environment.Response.StatusCode); // response
            });

            ConfigureWebApi(app);

            app.UseHelloWorld();
        }
Example #13
0
        public void Configuration(IAppBuilder app)
        {
            app.Use(async(environment, next) =>
            {
                // This executes when the request is coming in
                Console.WriteLine("Requesting: " + environment.Request.Path);
                await next();

                // This executes when the response is going out
                Console.WriteLine("Response: " + environment.Response.StatusCode);
            });

            ConfigureWebApi(app);

            app.UseHelloWorld();
        }
Example #14
0
        public void Configuration(IAppBuilder appBuilder)
        {
            //Middleware
            appBuilder.Use(async(enviroment, next) =>
            {
                Console.WriteLine($"Requesting : {enviroment.Request.Path}");

                await next();

                Console.WriteLine($"Response : {enviroment.Response.StatusCode}");
            });

            //Configure to use WebApi
            ConfigureWebApi(appBuilder);

            // Middleware - Low Level Component
            appBuilder.UseHelloWorld();
        }
Example #15
0
            public void Configuration(IAppBuilder app)
            {
                app.Use(async(context, next) =>
                {
                    Console.WriteLine("Requesting : " + context.Request.Path);

                    await next();

                    Console.WriteLine("Response: " + context.Response.StatusCode);
                });

                ConfigureWebApi(app);

                //app.Use<HelloWorldMiddleware>();
                app.UseHelloWorld();

                //app.UseWelcomePage();
            }
Example #16
0
        public void Configuration(IAppBuilder app)
        {
            /*  A - using app.Run*/
            //app.Run(environment =>
            //{
            //    return environment.Response.WriteAsync("Hello app.Run");
            //});

            /* B
             * 1 - Register all components with appBuilder
             * 2 - Katana looks for Invoke method (it matches AppFunc signature) via Reflection
             * 3 - Instantiates the component and gives the next component in the pipeline
             * 4 - Starts using it to process requests.**/
            //app.Use<HelloWorldComponent>();

            /*C - using AppBuilderExtension*/
            app.UseHelloWorld();
        }
Example #17
0
        public void TestingResponseRequest(IAppBuilder app)
        {
            app.Use(async(enviornment, next) =>
            {
                foreach (var pair in enviornment.Environment)
                {
                    Console.WriteLine("{0}:{1}, pair.Key, pair.Value");
                }
                await next();
            });
            //app.UseWelcomePage();

            //katana will call into to process at http requests
            //app.Run(context =>
            //{
            //	//every request that comes in will respond with Hello World
            //	return context.Response.WriteAsync("Hello World");
            //});

            //app.Use<HelloWorldComponent>();
            app.UseHelloWorld();
        }
Example #18
0
        public void Configuration(IAppBuilder app)
        {
            // Pipe line 1
            app.Use(async(context, next) =>
            {
                // can add a new key and pass to others
                context.Environment.Add("myPipeline", "pipleline 1");
                foreach (var pair in context.Environment)
                {
                    Console.WriteLine("{0}:{1}", pair.Key, pair.Value);
                }
                Console.WriteLine("*******************************");
                await next();
            });

            // make HelloWorldComponent invoke method async and put await code
            //app.UseHelloWorld();

            // Pipe line 2
            app.Use(async(context, next) =>
            {
                context.Environment["myPipeline"] = "pipleline 2";
                var response = context.Environment["owin.ResponseBody"] as Stream;
                using (var writer = new StreamWriter(response))
                {
                    writer.WriteLine("Helloo I am from another middle ware!");
                }
                Console.WriteLine("Pipe Line in second middleware: {0} ", context.Environment["myPipeline"]);
                Console.WriteLine("*******************************");
                Console.WriteLine("Requesting : {0}", context.Environment["owin.RequestPath"]);
                await next();
                Console.WriteLine("Response : {0}", context.Environment["owin.ResponseStatusCode"]);
                Console.WriteLine("Pipe Line in second middleware End: {0} ", context.Environment["myPipeline"]);
                Console.WriteLine("*******************************");
            });

            // Pipe line 3
            app.UseHelloWorld();
        }
Example #19
0
        public void Configuration(IAppBuilder app)
        {
            //app.Use(async (environment, next) =>
            //{
            //    foreach(var pair in environment.Environment)
            //    {
            //        Console.WriteLine("{0}:{1}", pair.Key, pair.Value);
            //    }
            //    await next();
            //});

            //app.Use(async (environment, next) =>
            //{
            //    var onTheWayIn = environment.Response;

            //    await next();

            //    var onTheWayOut = environment.Response;
            //});
            ConfigureWebApi(app);
            app.UseHelloWorld();
        }
Example #20
0
        public void Configuration(IAppBuilder app)
        {
            app.Use(async(context, next) =>
            {
                foreach (var pair in context.Environment)
                {
                    Console.WriteLine(pair);
                }

                await next();
            });

            app.Use(async(context, next) =>
            {
                Console.WriteLine($"Requesting: {context.Request.Path}");
                await next(); // remember writing this in hello world component? nope, try to shuffle component order

                //we can manipulate response after the next state
                Console.WriteLine($"Response: {context.Response.StatusCode}");
            });

            app.UseHelloWorld();
        }
Example #21
0
        public void Configuration(IAppBuilder appBuilder)
        {
            appBuilder.Use(async(environment, next) =>
            {
                Console.WriteLine("*** Enviroment Variables ***");
                foreach (var pair in environment.Environment)
                {
                    Console.WriteLine("{0}:{1}", pair.Key, pair.Value);
                }

                await next();
            });

            appBuilder.Use(async(environment, next) =>
            {
                Console.WriteLine("Requesting Path = {0}", environment.Request.Path);

                await next();

                Console.WriteLine("Response Status Code = {0}", environment.Response.StatusCode);
            });

            appBuilder.UseHelloWorld();
        }
Example #22
0
        /// <summary>
        ///     Configure Katana by adding middleware into the OWIN pipeline.
        /// </summary>
        /// <param name="appBuilder">
        ///     Describes how the application is going to behave and response to Http requests.
        /// </param>
        public void Configuration(IAppBuilder appBuilder)
        {
            // midleware registered before HelloWorld
            appBuilder.Use(async(environment, next) =>
            {
                // a way of logging what the environment is
                foreach (var entry in environment.Environment)
                {
                    Console.WriteLine($"{entry.Key} : {entry.Value}");
                }

                // chain processing to the next component in the pipeline
                await next();
            });

            // Inserts a middleware into the OWIN pipeline
            //appBuilder.Use<HelloWorldComponent>();

            //by using syntactic sugar
            appBuilder.UseHelloWorld();

            return;

            appBuilder.UseWelcomePage();

            // This Run() method is a method Katana will call into to process all Http request.
            appBuilder.Run(context =>
            {
                // on this 'context' object I have access to info about the request,
                // so I could look at authentication properties,
                // the env properties - which contains all the info about the request:
                //                      Http headers, the cookies, the path, the verb,
                // and also the request object & response object.
                return(context.Response.WriteAsync("Hellow with Katana!"));
            });
        }
Example #23
0
 public void Configuration(IAppBuilder app)
 {
     //app.Use<HelloWorldComponent>(); ou
     app.UseHelloWorld();
 }
Example #24
0
 public void Configuration(IAppBuilder app)
 {
     //app.Use<HelloWorldComponent>(); ou
     app.UseHelloWorld();
 }
Example #25
0
        public void Configuration(IAppBuilder app)
        {
            // Use katana specific welcome page
            //app.UseWelcomePage();

            // Takes one param of type IOwinContext and returns a Task - Component
            //app.Run(ctx => { return ctx.Response.WriteAsync("Hello World!"); });

            // Writing anynomous Middleware
            // without creating class and extension method
            app.Use(
                async (env, next) =>
                    {
                        foreach (var pair in env.Environment)
                        {
                            Console.WriteLine("{0}:{1}", pair.Key, pair.Value);
                        }

                        await next();
                    });

            // Another component
            app.Use(
                async (env, next) =>
                    {
                        // All this is request
                        foreach (var pair in env.Environment)
                        {
                            Console.WriteLine("Requesting: " + env.Request.Path);
                        }

                        await next();

                        // All this is response
                        Console.WriteLine("Response: " + env.Response.StatusCode);
                    });

            // Web API stuff
            // If this route is matched no other components are executed since the request matched with the response
            ConfigureWebApi(app);

            // Register new component
            //app.Use<HelloWorldComponent>();

            // Using extension method to call new HelloWorldComponent
            app.UseHelloWorld();
        }
 public void Configuration(IAppBuilder app)
 {
     app.UseHelloWorld();
 }
Example #27
0
 private static void Configure(IAppBuilder app)
 {
     app.UseHelloWorld();
 }