requireSecure

fun requireSecure(baseUrl: String, hasCredentials: Boolean, what: String = "an API key")

Throws IllegalArgumentException when baseUrl is http:// and hasCredentials is true and the host is not a loopback address. https:// is always accepted, and so is http:// when no credentials are configured (the caller then has nothing to leak). The host is judged by its literal form (localhost, 127.0.0.0/8, ::1) and never resolved, so a hostname that merely resolves to a local address does not qualify.