def build_link_header(links):
    """Builds a Link header according to RFC 5988.

    The format is a dict where the keys are the URI with the value being
    a dict of link parameters:

        {
            '/page=3': {
                'rel': 'next',
            },
            '/page=1': {
                'rel': 'prev',
            },
            ...
        }

    See https://tools.ietf.org/html/rfc5988#section-6.2.2 for registered
    link relation types.
    """
    _links = []
    for uri, params in links.items():
        link = ['<' + uri + '>']
        for key, value in params.items():
            link.append(key + '="' + str(value) + '"')
        _links.append('; '.join(link))
    return ', '.join(_links)
