reworked the CacheController Class
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
package org.mosad.thecitadelofricks.controller
|
||||
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.io.OutputStreamWriter
|
||||
|
||||
|
||||
class CachetAPIController {
|
||||
|
||||
companion object {
|
||||
|
||||
private val logger: Logger = LoggerFactory.getLogger(CachetAPIController::class.java)
|
||||
|
||||
fun postTotalRequests(totalRequests: Int) {
|
||||
logger.info("sending post request ...")
|
||||
|
||||
val currentTime = System.currentTimeMillis() / 1000
|
||||
val data = mapOf(Pair("value", totalRequests.toString()), Pair("timestamp", currentTime.toString()))
|
||||
|
||||
val url = URL("https://status.mosad.xyz/api/v1/metrics/1/points")
|
||||
val connection = url.openConnection() as HttpURLConnection
|
||||
connection.setRequestProperty("X-Cachet-Token", "h0103Wix5xhhNH5tk5KU")
|
||||
connection.requestMethod = "POST"
|
||||
connection.doOutput = true
|
||||
|
||||
val writer = OutputStreamWriter(connection.outputStream)
|
||||
writer.write(data.toString())
|
||||
writer.flush()
|
||||
writer.close()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user