Exemplo n.º 1
0
        private static void SetupMediaTypes(SuperscribeOwinOptions config)
        {
            config.MediaTypeHandlers.Add(
                "application/json",
                new MediaTypeHandler
            {
                Write = (env, o) => env.WriteResponse(JsonConvert.SerializeObject(o)),
                Read  = (env, type) =>
                {
                    object obj;
                    using (var reader = new StreamReader(env.GetRequestBody()))
                    {
                        obj = JsonConvert.DeserializeObject(reader.ReadToEnd(), type);
                    }
                    ;

                    return(obj);
                }
            });

            config.MediaTypeHandlers.Add(
                "text/html",
                new MediaTypeHandler {
                Write = (env, o) => env.WriteResponse(o.ToString())
            });
        }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            var config = new SuperscribeOwinOptions();

            config.MediaTypeHandlers.Add(
                "application/json",
                new MediaTypeHandler
            {
                Write = (env, o) => env.WriteResponse(JsonConvert.SerializeObject(o)),
                Read  = (env, type) =>
                {
                    object obj;
                    using (var reader = new StreamReader(env.GetRequestBody()))
                    {
                        obj = JsonConvert.DeserializeObject(reader.ReadToEnd(), type);
                    };

                    return(obj);
                }
            });

            var engine = OwinRouteEngineFactory.Create(config);

            app.UseSuperscribeRouter(engine)
            .UseSuperscribeHandler(engine);
        }
Exemplo n.º 3
0
        public void Configuration(IAppBuilder app)
        {
            var config = new SuperscribeOwinOptions();
            SetupMediaTypes(config);

            var engine = OwinRouteEngineFactory.Create(config);

            app.UseSuperscribeRouter(engine).UseSuperscribeHandler(engine);
        }
Exemplo n.º 4
0
        public void Configuration(IAppBuilder app)
        {
            var config = new SuperscribeOwinOptions();

            SetupMediaTypes(config);

            var engine = OwinRouteEngineFactory.Create(config);

            app.UseSuperscribeRouter(engine).UseSuperscribeHandler(engine);
        }
Exemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            var options = new SuperscribeOwinOptions();
            SetupMediaTypes(options);

            var define = OwinRouteEngineFactory.Create(options);
            define.Route("/", o => "Hello World");

            app.UseSuperscribeRouter(define).UseSuperscribeHandler(define);
        }
Exemplo n.º 6
0
        public void Configuration(IAppBuilder app)
        {
            var options = new SuperscribeOwinOptions();

            SetupMediaTypes(options);

            var define = OwinRouteEngineFactory.Create(options);

            define.Route("/", o => "Hello World");

            app.UseSuperscribeRouter(define).UseSuperscribeHandler(define);
        }
Exemplo n.º 7
0
        public void Configuration(IAppBuilder app)
        {
            var config = new SuperscribeOwinOptions();

            config.MediaTypeHandlers.Add(
                "application/json",
                new MediaTypeHandler {
                Write = (env, o) => env.WriteResponse(JsonConvert.SerializeObject(o))
            });

            var engine = OwinRouteEngineFactory.Create(config);

            app.UseSuperscribeRouter(engine);
        }
Exemplo n.º 8
0
        private static void SetupMediaTypes(SuperscribeOwinOptions config)
        {
            config.MediaTypeHandlers.Add(
                "application/json",
                new MediaTypeHandler
                    {
                        Write = (env, o) => env.WriteResponse(JsonConvert.SerializeObject(o)),
                        Read = (env, type) =>
                            {
                                object obj;
                                using (var reader = new StreamReader(env.GetRequestBody()))
                                {
                                    obj = JsonConvert.DeserializeObject(reader.ReadToEnd(), type);
                                }
                                ;

                                return obj;
                            }
                    });

            config.MediaTypeHandlers.Add(
                "text/html",
                new MediaTypeHandler { Write = (env, o) => env.WriteResponse(o.ToString()) });
        }
Exemplo n.º 9
0
        public static IOwinRouteEngine Create(SuperscribeOwinOptions options)
        {
            var engine = new OwinRouteEngine(options);

            return(engine);
        }
Exemplo n.º 10
0
 public OwinRouteEngine(SuperscribeOwinOptions options)
     : base(options)
 {
     this.Config = options;
 }
Exemplo n.º 11
0
 public static IOwinRouteEngine Create(SuperscribeOwinOptions options)
 {
     var engine = new OwinRouteEngine(options);
     return engine;
 }
Exemplo n.º 12
0
 public OwinRouteEngine(SuperscribeOwinOptions options)
     : base(options)
 {
     this.Config = options;
 }