A decorator that allows you to override the default output format for an API

def default_input_format(content_type='application/json', apply_globally=False, api=None):
    """A decorator that allows you to override the default output format for an API"""
    def decorator(formatter):
        formatter = hug.output_format.content_type(content_type)(formatter)
        if apply_globally:
            hug.defaults.input_format[content_type] = formatter
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(formatter)
            apply_to_api.http.set_input_format(content_type, formatter)
        return formatter
    return decorator