<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
using Microsoft.AspNet.FileProviders;
using Microsoft.Dnx.Runtime;
using MakingSense.AspNet.Documentation;

namespace MakingSense.AspNet.HypermediaApi.Seed
{
    public class Startup
    {
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
        }

        public void Configure(IApplicationBuilder app, IApplicationEnvironment appEnv)
        {
            app.UseStaticFiles();

            UseDocumentation(app, appEnv);

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }

        private static void UseDocumentation(IApplicationBuilder app, IApplicationEnvironment appEnv)
        {
            var documentationFilesProvider = new PhysicalFileProvider(appEnv.ApplicationBasePath);
            app.UseDocumentation(new DocumentationOptions()
            {
                DefaultFileName = "index",
                RequestPath = "/docs",
                NotFoundHtmlFile = documentationFilesProvider.GetFileInfo("DocumentationTemplates\\NotFound.html"),
                LayoutFile = documentationFilesProvider.GetFileInfo("DocumentationTemplates\\Layout.html")
            });
        }
    }<commit_msg>Add NotFound and ErrorHandling middlewares<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Http;
using Microsoft.Framework.DependencyInjection;
using Microsoft.AspNet.FileProviders;
using Microsoft.Dnx.Runtime;
using MakingSense.AspNet.Documentation;
using MakingSense.AspNet.HypermediaApi.Formatters;
using MakingSense.AspNet.HypermediaApi.ValidationFilters;

namespace MakingSense.AspNet.HypermediaApi.Seed
{
    public class Startup
    {
        // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options =>
            {
                options.OutputFormatters.Clear();
                options.OutputFormatters.Add(new HypermediaApiJsonOutputFormatter());

                options.InputFormatters.Clear();
                options.InputFormatters.Add(new HypermediaApiJsonInputFormatter());

                options.Filters.Add(new PayloadValidationFilter());
                options.Filters.Add(new RequiredPayloadFilter());
            });
        }

        public void Configure(IApplicationBuilder app, IApplicationEnvironment appEnv)
        {
            app.UseApiErrorHandler();


            app.UseMvc();

            app.UseStaticFiles();

            UseDocumentation(app, appEnv);

            app.UseNotFoundHandler();
        }

        private static void UseDocumentation(IApplicationBuilder app, IApplicationEnvironment appEnv)
        {
            var documentationFilesProvider = new PhysicalFileProvider(appEnv.ApplicationBasePath);
            app.UseDocumentation(new DocumentationOptions()
            {
                DefaultFileName = "index",
                RequestPath = "/docs",
                NotFoundHtmlFile = documentationFilesProvider.GetFileInfo("DocumentationTemplates\\NotFound.html"),
                LayoutFile = documentationFilesProvider.GetFileInfo("DocumentationTemplates\\Layout.html")
            });
        }
    }
{'fraction_non_alphanumeric': 0.08250736672917225, 'fraction_numerical': 0.0032145727297080095, 'mean_word_length': 2.726546906187625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3627218', 'n_tokens_mistral': 912, 'n_tokens_neox': 886, 'n_words': 167}