mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Main address now redirects to /server on HTTP servers #668
This commit is contained in:
parent
addd463406
commit
0b6d6cb687
@ -44,9 +44,14 @@ public class ResponseHandler extends TreePageHandler {
|
||||
ServerPageHandler serverPageHandler = new ServerPageHandler();
|
||||
registerPage("network", serverPageHandler);
|
||||
registerPage("server", serverPageHandler);
|
||||
if (webServer.isAuthRequired()) {
|
||||
registerPage("", new RootPageHandler(this));
|
||||
}
|
||||
registerPage("", webServer.isAuthRequired()
|
||||
? new RootPageHandler(this)
|
||||
: new PageHandler() {
|
||||
@Override
|
||||
public Response getResponse(Request request, List<String> target) {
|
||||
return new RedirectResponse("/server");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void registerWebAPIPages() {
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.djrapitops.plan.system.webserver.response;
|
||||
|
||||
import com.djrapitops.plan.system.locale.Locale;
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Rsl1122
|
||||
* @since 3.5.2
|
||||
@ -8,6 +13,12 @@ public class RedirectResponse extends Response {
|
||||
|
||||
public RedirectResponse(String direct) {
|
||||
super.setHeader("HTTP/1.1 302 Found");
|
||||
super.setContent("Location: " + direct);
|
||||
super.setContent(direct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(HttpExchange exchange, Locale locale) throws IOException {
|
||||
responseHeaders.set("Location", getContent());
|
||||
super.send(exchange, locale);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public abstract class Response {
|
||||
private String header;
|
||||
private String content;
|
||||
|
||||
private Headers responseHeaders;
|
||||
protected Headers responseHeaders;
|
||||
|
||||
public Response(ResponseType type) {
|
||||
this.type = type.get();
|
||||
|
Loading…
Reference in New Issue
Block a user