Fixed /server returning 500

This commit is contained in:
Rsl1122 2019-08-31 11:46:11 +03:00
parent 41aa8a1ba0
commit 5b3f08f870
4 changed files with 4 additions and 84 deletions

View File

@ -100,7 +100,7 @@ public class ResponseFactory {
public Response networkPageResponse() {
try {
return new NetworkPageResponse(pageFactory.networkPage());
return new PageResponse(pageFactory.networkPage());
} catch (ParseException e) {
return internalErrorResponse(e, "Failed to parse network page");
}
@ -201,7 +201,7 @@ public class ResponseFactory {
public Response playerPageResponse(UUID playerUUID) {
try {
return new PlayerPageResponse(playerUUID, pageFactory.playerPage(playerUUID).toHtml());
return new PageResponse(pageFactory.playerPage(playerUUID));
} catch (IllegalStateException e) {
return playerNotFound404();
} catch (ParseException e) {

View File

@ -1,33 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.delivery.webserver.response.pages;
import com.djrapitops.plan.delivery.rendering.pages.NetworkPage;
import com.djrapitops.plan.exceptions.ParseException;
/**
* Response for /network page.
*
* @author Rsl1122
*/
public class NetworkPageResponse extends PageResponse {
public NetworkPageResponse(NetworkPage networkPage) throws ParseException {
setHeader("HTTP/1.1 200 OK");
setContent(networkPage.toHtml());
}
}

View File

@ -40,7 +40,8 @@ public class PageResponse extends Response {
}
public PageResponse(Page page) throws ParseException {
super(ResponseType.HTML);
this(ResponseType.HTML);
super.setHeader("HTTP/1.1 200 OK");
setContent(page.toHtml());
}

View File

@ -1,48 +0,0 @@
/*
* This file is part of Player Analytics (Plan).
*
* Plan is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License v3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Plan is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
*/
package com.djrapitops.plan.delivery.webserver.response.pages;
import java.util.Objects;
import java.util.UUID;
/**
* @author Rsl1122
*/
public class PlayerPageResponse extends PageResponse {
private final UUID uuid;
public PlayerPageResponse(UUID uuid, String html) {
super.setHeader("HTTP/1.1 200 OK");
super.setContent(html);
this.uuid = uuid;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PlayerPageResponse)) return false;
if (!super.equals(o)) return false;
PlayerPageResponse that = (PlayerPageResponse) o;
return Objects.equals(uuid, that.uuid);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), uuid);
}
}