<commit_before>"""
    harpseal.web.routes
    ~~~~~~~~~~~~~~~~~~~

"""

class Router(object):
    pass<commit_msg>Add: Router and Response object which inherited from StreamResponse<commit_after>"""
    harpseal.web.routes
    ~~~~~~~~~~~~~~~~~~~

"""
import asyncio
import json

from aiohttp import web

__all__ = ['Router', 'Handler']

class Router(object):
    def __init__(self, app):
        self.handler = Handler()
        app.router.add_route('GET', r'/plugins/{name}', self.handler.plugins)


class Response(web.StreamResponse):
    def __init__(self, body=None, status=200, reason=None, headers=None):
        super().__init__(status=status, reason=reason, headers=headers)

        if body is None:
            raise ValueError("the argument 'body' is positional argument.")
        self.headers['Content-Type'] = self.content_type = 'application/json'
        self.body = body

    @property
    def body(self):
        return self._body

    @body.setter
    def body(self, data):
        if data is not None and not isinstance(data, dict):
            raise TypeError('data argument must be dict.')

        if self.charset is None:
            self.charset = 'utf-8'

        body = json.dumps(data).encode(self.charset)
        self._body = body
        self.content_length = len(body) if body is not None else 0

    @asyncio.coroutine
    def write_eof(self):
        body = self._body
        if body is not None:
            self.write(body)
        yield from super().write_eof()


class Handler(object):
    def __init__(self):
        pass

    @asyncio.coroutine
    def plugins(self, req):
        name = req.match_info.get('name')
        return Response({'name': name})
{'fraction_non_alphanumeric': 0.13494401885680612, 'fraction_numerical': 0.0029463759575721863, 'mean_word_length': 2.7074235807860263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2605205', 'n_tokens_mistral': 511, 'n_tokens_neox': 495, 'n_words': 133}