예제 #1
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);
        }
예제 #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)) });

            var engine = OwinRouteEngineFactory.Create(config);

            app.UseSuperscribeRouter(engine);
        }