<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Dashen.Controllers
{
	public class StaticController : ApiController
	{
		private const string Prefix = "Dashen.Static.";
		private readonly Dictionary<string, Func<Stream>> _resources;

		public StaticController()
		{
			var assembly = GetType().Assembly;

			_resources = assembly
				.GetManifestResourceNames()
				.ToDictionary(
					name => name,
					name => new Func<Stream>(() => assembly.GetManifestResourceStream(name)),
					StringComparer.OrdinalIgnoreCase);
		}

		public HttpResponseMessage GetDispatch(string url = "")
		{
			var path = Prefix + url.Replace('/', '.');
			
			if (_resources.ContainsKey(path) == false)
			{
				return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
			}

			var stream = _resources[path].Invoke();

			return new HttpResponseMessage
			{
				Content = new StreamContent(stream)
			};
		}
	}
}<commit_msg>staticController: do prefix trimming on dictionary creation<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Dashen.Controllers
{
	public class StaticController : ApiController
	{
		private const string Prefix = "Dashen.Static.";
		private readonly Dictionary<string, Func<Stream>> _resources;

		public StaticController()
		{
			var assembly = GetType().Assembly;

			_resources = assembly
				.GetManifestResourceNames()
				.Where(name => name.StartsWith(Prefix))
				.ToDictionary(
					name => name.Substring(Prefix.Length),
					name => new Func<Stream>(() => assembly.GetManifestResourceStream(name)),
					StringComparer.OrdinalIgnoreCase);
		}

		public HttpResponseMessage GetDispatch(string url = "")
		{
			var path = url.Replace('/', '.');
			
			if (_resources.ContainsKey(path) == false)
			{
				return new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound };
			}

			var stream = _resources[path].Invoke();

			return new HttpResponseMessage
			{
				Content = new StreamContent(stream)
			};
		}
	}
}
{'fraction_non_alphanumeric': 0.11464968152866242, 'fraction_numerical': 0.0, 'mean_word_length': 3.975113122171946, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 16, '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': '6026905', 'n_tokens_mistral': 751, 'n_tokens_neox': 635, 'n_words': 149}