added a configuration via config.xml file
All checks were successful
continuous-integration/drone/push Build is passing

* the config file contains the Mensa name and URL, the Cachet Base-URL and API-Key
This commit is contained in:
2019-10-28 18:39:44 +01:00
parent 3177be1bf0
commit dd064d63af
4 changed files with 154 additions and 21 deletions

View File

@ -36,14 +36,12 @@ class CachetAPIController {
companion object {
private val logger: Logger = LoggerFactory.getLogger(CachetAPIController::class.java)
private const val baseURL = "https://status.mosad.xyz"
private const val apiKey = "" //TODO
private var oldTotalRequests = 0
fun postTotalRequests() {
try {
val url = URL("$baseURL/api/v1/metrics/1/points")
val url = URL("${StartupController.getCachetBaseURL()}/api/v1/metrics/1/points")
val jsonInputString = "{\"value\": ${getTotalRequests() -oldTotalRequests}, \"timestamp\": \"${(System.currentTimeMillis() / 1000)}\"}"
oldTotalRequests = getTotalRequests()
@ -51,7 +49,7 @@ class CachetAPIController {
con.requestMethod = "POST"
con.setRequestProperty("Content-Type", "application/json; utf-8")
con.setRequestProperty("Accept", "application/json")
con.setRequestProperty("X-Cachet-Token", apiKey)
con.setRequestProperty("X-Cachet-Token", StartupController.getCachetAPIKey())
con.doOutput = true
val os = con.outputStream