def validate_extension(extension):
    """
    Checks that the API extension starts and does not end with a '/'. An error is
    raised, at which point the application exits, if the extension does not meet
    these validation rules.

    :param extension: The extension for the API
    """
    extension = extension.strip()

    if not extension.startswith("/"):
        raise ValueError("must start with '/'")
    if extension.endswith("/"):
        raise ValueError("must not end with '/'")

    return extension