Skip to content

Commit ef4e95d

Browse files
committed
resolve: add Utils.methodNotAllowed
- Switch to 405 / method not allowed in InstanceHandler
1 parent 8e11556 commit ef4e95d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

api/src/main/java/xyz/gianlu/librespot/api/Utils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,9 @@ public static void internalError(@NotNull HttpServerExchange exchange, @NotNull
8383
exchange.setStatusCode(StatusCodes.INTERNAL_SERVER_ERROR);
8484
exchange.getResponseSender().send(String.format(INTERNAL_ERROR_BODY, reason));
8585
}
86+
87+
public static void methodNotAllowed(@NotNull HttpServerExchange exchange) {
88+
exchange.setStatusCode(StatusCodes.METHOD_NOT_ALLOWED);
89+
exchange.getResponseSender().send(StatusCodes.METHOD_NOT_ALLOWED_STRING);
90+
}
8691
}

api/src/main/java/xyz/gianlu/librespot/api/handlers/InstanceHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected void handleRequest(@NotNull HttpServerExchange exchange, @NotNull Sess
104104
session.close();
105105
break;
106106
default:
107-
Utils.invalidParameter(exchange, "action");
107+
Utils.methodNotAllowed(exchange);
108108
break;
109109
}
110110
break;
@@ -150,7 +150,7 @@ protected void handleRequest(@NotNull HttpServerExchange exchange, @NotNull Sess
150150
session.close();
151151
break;
152152
default:
153-
Utils.invalidParameter(exchange, "action");
153+
Utils.methodNotAllowed(exchange);
154154
break;
155155
}
156156
break;

0 commit comments

Comments
 (0)