main #8
2 changed files with 9 additions and 4 deletions
|
@ -34,10 +34,12 @@ fun Application.configureRouting(client: HttpClient) {
|
||||||
// get meow timeout
|
// get meow timeout
|
||||||
get("/meowTimeout") {
|
get("/meowTimeout") {
|
||||||
if (meowTimedOut) {
|
if (meowTimedOut) {
|
||||||
call.response.status(HttpStatusCode(500, "FUCK"))
|
call.response.status(HttpStatusCode(423, "Timed Out"))
|
||||||
|
call.respondText("Timed Out")
|
||||||
}
|
}
|
||||||
if (!meowTimedOut) {
|
if (!meowTimedOut) {
|
||||||
call.response.status(HttpStatusCode(200, "OKAY"))
|
call.response.status(HttpStatusCode(100, "Not Timed Out"))
|
||||||
|
call.respondText("Not Timed Out")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,13 +47,16 @@ fun Application.configureRouting(client: HttpClient) {
|
||||||
@Suppress("ktlint:standard:comment-wrapping")
|
@Suppress("ktlint:standard:comment-wrapping")
|
||||||
post("/meow") {
|
post("/meow") {
|
||||||
if (call.receiveText() == Config().superSecret) {
|
if (call.receiveText() == Config().superSecret) {
|
||||||
|
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||||
println("secret code received, bypassing timeout")
|
println("secret code received, bypassing timeout")
|
||||||
makePost(client, getMeow(), Config().instanceDomain)
|
makePost(client, getMeow(), Config().instanceDomain)
|
||||||
println("meow sent!")
|
println("meow sent!")
|
||||||
} else {
|
} else {
|
||||||
if (meowTimedOut) {
|
if (meowTimedOut) {
|
||||||
|
call.response.status(HttpStatusCode(423, "Timed Out"))
|
||||||
call.respondText("still Sleeping...")
|
call.respondText("still Sleeping...")
|
||||||
} else {
|
} else {
|
||||||
|
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||||
makePost(client, getMeow(), Config().instanceDomain)
|
makePost(client, getMeow(), Config().instanceDomain)
|
||||||
meowTimer()
|
meowTimer()
|
||||||
call.respondText("meow sent!")
|
call.respondText("meow sent!")
|
||||||
|
|
|
@ -14,12 +14,12 @@ function sendMeow(endpoint) {
|
||||||
|
|
||||||
async function getMeowTimeout(endpoint) {
|
async function getMeowTimeout(endpoint) {
|
||||||
const response = await fetch(endpoint)
|
const response = await fetch(endpoint)
|
||||||
if (response.status === 500) {
|
if (response.status === 423) {
|
||||||
meowButton.disabled=true;
|
meowButton.disabled=true;
|
||||||
meowButton.innerHTML = "<span>sleeping...</span>";
|
meowButton.innerHTML = "<span>sleeping...</span>";
|
||||||
console.warn("TIMED OUT")
|
console.warn("TIMED OUT")
|
||||||
}
|
}
|
||||||
if (response.status === 200) {
|
if (response.status === 100) {
|
||||||
meowButton.disabled=false;
|
meowButton.disabled=false;
|
||||||
meowButton.innerHTML = "<span>meow</span>";
|
meowButton.innerHTML = "<span>meow</span>";
|
||||||
console.warn("NOT TIMED OUT")
|
console.warn("NOT TIMED OUT")
|
||||||
|
|
Loading…
Reference in a new issue