change status codes
This commit is contained in:
parent
c0538f889e
commit
5d108a2781
2 changed files with 9 additions and 4 deletions
|
@ -34,10 +34,12 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
// get meow timeout
|
||||
get("/meowTimeout") {
|
||||
if (meowTimedOut) {
|
||||
call.response.status(HttpStatusCode(500, "FUCK"))
|
||||
call.response.status(HttpStatusCode(423, "Timed Out"))
|
||||
call.respondText("Timed Out")
|
||||
}
|
||||
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")
|
||||
post("/meow") {
|
||||
if (call.receiveText() == Config().superSecret) {
|
||||
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||
println("secret code received, bypassing timeout")
|
||||
makePost(client, getMeow(), Config().instanceDomain)
|
||||
println("meow sent!")
|
||||
} else {
|
||||
if (meowTimedOut) {
|
||||
call.response.status(HttpStatusCode(423, "Timed Out"))
|
||||
call.respondText("still Sleeping...")
|
||||
} else {
|
||||
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||
makePost(client, getMeow(), Config().instanceDomain)
|
||||
meowTimer()
|
||||
call.respondText("meow sent!")
|
||||
|
|
|
@ -14,12 +14,12 @@ function sendMeow(endpoint) {
|
|||
|
||||
async function getMeowTimeout(endpoint) {
|
||||
const response = await fetch(endpoint)
|
||||
if (response.status === 500) {
|
||||
if (response.status === 423) {
|
||||
meowButton.disabled=true;
|
||||
meowButton.innerHTML = "<span>sleeping...</span>";
|
||||
console.warn("TIMED OUT")
|
||||
}
|
||||
if (response.status === 200) {
|
||||
if (response.status === 100) {
|
||||
meowButton.disabled=false;
|
||||
meowButton.innerHTML = "<span>meow</span>";
|
||||
console.warn("NOT TIMED OUT")
|
||||
|
|
Loading…
Reference in a new issue