コード例 #1
0
        public static async Task HandleGetRequest(HttpContext context)
        {
            var result = await CompositionHandler.HandleGetRequest(context);

            if (result.StatusCode == StatusCodes.Status200OK)
            {
                string json = JsonConvert.SerializeObject(result.ViewModel, GetSettings(context));
                context.Response.ContentType = "application/json; charset=utf-8";
                await context.Response.WriteAsync(json);
            }
            else
            {
                context.Response.StatusCode = result.StatusCode;
            }
        }
コード例 #2
0
        public static async Task HandleGetRequest(HttpContext context)
        {
            var result = await CompositionHandler.HandleGetRequest(context);

            if (result.StatusCode == StatusCodes.Status200OK)
            {
                // For the purposes of the demo, we're not respecting the HTTP Accept header and assuming that a JSON response is OK.
                context.Response.ContentType = "application/json; charset=utf-8";
                string json = JsonConvert.SerializeObject(result.ViewModel, GetSettings(context));
                await context.Response.WriteAsync(json);
            }
            else
            {
                context.Response.StatusCode = result.StatusCode;
            }
        }