mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Merge pull request #239 from TeamPiped/json-data
Handle JSON data better
This commit is contained in:
commit
f08c6c4ebf
2 changed files with 7 additions and 7 deletions
|
@ -283,7 +283,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||
}
|
||||
})).map(POST, "/user/playlists/create", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try {
|
||||
var name = Constants.mapper.readTree(request.loadBody().getResult().asArray()).get("name").asText();
|
||||
var name = Constants.mapper.readTree(request.loadBody().getResult().asArray()).get("name").textValue();
|
||||
return getJsonResponse(ResponseHelper.createPlaylist(request.getHeader(AUTHORIZATION), name), "private");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
|
@ -297,8 +297,8 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||
})).map(POST, "/user/playlists/add", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try {
|
||||
var json = Constants.mapper.readTree(request.loadBody().getResult().asArray());
|
||||
var playlistId = json.get("playlistId").asText();
|
||||
var videoId = json.get("videoId").asText();
|
||||
var playlistId = json.get("playlistId").textValue();
|
||||
var videoId = json.get("videoId").textValue();
|
||||
return getJsonResponse(ResponseHelper.addToPlaylistResponse(request.getHeader(AUTHORIZATION), playlistId, videoId), "private");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
|
@ -306,8 +306,8 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||
})).map(POST, "/user/playlists/remove", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try {
|
||||
var json = Constants.mapper.readTree(request.loadBody().getResult().asArray());
|
||||
var playlistId = json.get("playlistId").asText();
|
||||
var index = json.get("index").asInt();
|
||||
var playlistId = json.get("playlistId").textValue();
|
||||
var index = json.get("index").intValue();
|
||||
return getJsonResponse(ResponseHelper.removeFromPlaylistResponse(request.getHeader(AUTHORIZATION), playlistId, index), "private");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
|
@ -315,7 +315,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
|||
})).map(POST, "/user/playlists/delete", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try {
|
||||
var json = Constants.mapper.readTree(request.loadBody().getResult().asArray());
|
||||
var playlistId = json.get("playlistId").asText();
|
||||
var playlistId = json.get("playlistId").textValue();
|
||||
return getJsonResponse(ResponseHelper.deletePlaylistResponse(request.getHeader(AUTHORIZATION), playlistId), "private");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
|
|
|
@ -2,6 +2,6 @@ package me.kavin.piped.utils.resp;
|
|||
|
||||
public class InvalidRequestResponse {
|
||||
|
||||
public String message = "Invalid request sent.";
|
||||
public String error = "Invalid request sent.";
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue