implemented "Forward" path handler to catch lookups of former index.php
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/* © SRSoftware 2024 */
|
||||
package de.srsoftware.cal;
|
||||
|
||||
import static de.srsoftware.tools.Optionals.nullable;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.tools.HttpError;
|
||||
import de.srsoftware.tools.PathHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Forward extends PathHandler {
|
||||
|
||||
@Override
|
||||
public boolean doGet(String path, HttpExchange ex) throws IOException {
|
||||
var params = queryParam(ex);
|
||||
var show = nullable(params.get("show"));
|
||||
if (show.isPresent()) return sendRedirect(ex,"/static/event?id="+show.get());
|
||||
LOG.log(System.Logger.Level.WARNING,"Call to {0} with query: {1} – no handler defined",path,params);
|
||||
return sendContent(ex, HttpError.of(400,"Unknwon request"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user