ca.sm360.cronitor.client.urlgenerators.CommandUrlGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cronitor-client Show documentation
Show all versions of cronitor-client Show documentation
cronitor-client is a simple Java library designed to help you monitoring, with www.cronitor.io, the routines of your Java projects
package ca.sm360.cronitor.client.urlgenerators;
import org.apache.http.client.utils.URIBuilder;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
public abstract class CommandUrlGenerator {
private static final String BASE_URL = "https://cronitor.link/%s";
public URL buildURI(String monitorCode, String authKey) throws URISyntaxException, MalformedURLException {
String baseUrl = String.format(BASE_URL, monitorCode);
URIBuilder uriBuilder = generateURIBuilder(baseUrl);
if (authKey != null) {
uriBuilder.addParameter("auth_key", authKey);
}
return uriBuilder.build().toURL();
}
protected abstract URIBuilder generateURIBuilder(String baseURL) throws URISyntaxException;
}