def expose(template=None,
           generic=False,
           route=None,
           **kw):
    '''
    Decorator used to flag controller methods as being "exposed" for
    access via HTTP, and to configure that access.
    :param template: The path to a template, relative to the base template
                     directory.  Can also be passed a string representing
                     a special or custom renderer, such as ``'json'`` for
                     :ref:`expose_json`.
    :param content_type: The content-type to use for this template.
    :param generic: A boolean which flags this as a "generic" controller,
                    which uses generic functions based upon
                    ``functools.singledispatch`` generic functions.  Allows you
                    to split a single controller into multiple paths based upon
                    HTTP method.
    :param route: The name of the path segment to match (excluding
                  separator characters, like `/`).  Defaults to the name of
                  the function itself, but this can be used to resolve paths
                  which are not valid Python function names, e.g., if you
                  wanted to route a function to `some-special-path'.
    '''
    content_type = kw.get('content_type', 'text/html')
    if template == 'json':
        content_type = 'application/json'
    def decorate(f):
        f.exposed = True
        cfg = _cfg(f)
        cfg['explicit_content_type'] = 'content_type' in kw
        if route:
            from pecan import routing
            if cfg.get('generic_handler'):
                raise ValueError(
                    'Path segments cannot be overridden for generic '
                    'controllers.'
                )
            routing.route(route, f)
        cfg['content_type'] = content_type
        cfg.setdefault('template', []).append(template)
        cfg.setdefault('content_types', {})[content_type] = template
        if generic:
            if f.__name__ in ('_default', '_lookup', '_route'):
                raise ValueError(
                    'The special method %s cannot be used as a generic '
                    'controller' % f.__name__
                )
            cfg['generic'] = True
            cfg['generic_handlers'] = dict(DEFAULT=f)
            cfg['allowed_methods'] = []
            f.when = when_for(f)
        cfg['argspec'] = getargspec(f)
        return f
    return decorate