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:
@@ -14,7 +14,7 @@ dependencies {
|
||||
implementation("de.srsoftware:configuration.api:1.0.0")
|
||||
implementation("de.srsoftware:configuration.json:1.0.1")
|
||||
|
||||
implementation("de.srsoftware:tools.http:1.2.2")
|
||||
implementation("de.srsoftware:tools.http:1.2.3")
|
||||
implementation("de.srsoftware:tools.logging:1.2.0")
|
||||
implementation("de.srsoftware:tools.plugin:1.0.1")
|
||||
implementation("de.srsoftware:tools.util:1.3.0")
|
||||
|
||||
@@ -4,10 +4,7 @@ package de.srsoftware.cal.app;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import de.srsoftware.cal.ApiEndpoint;
|
||||
import de.srsoftware.cal.BaseImporter;
|
||||
import de.srsoftware.cal.IndexHandler;
|
||||
import de.srsoftware.cal.StaticHandler;
|
||||
import de.srsoftware.cal.*;
|
||||
import de.srsoftware.cal.db.Database;
|
||||
import de.srsoftware.cal.db.MariaDB;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
@@ -64,7 +61,8 @@ public class Application {
|
||||
HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
|
||||
var staticPages = new StaticHandler(staticPath).bindPath("/static").on(server);
|
||||
new IndexHandler(staticPages).bindPath("/").on(server);
|
||||
new ApiEndpoint(db).bindPath(("/api")).on(server);
|
||||
new ApiEndpoint(db).bindPath("/api").on(server);
|
||||
new Forward().bindPath("/index.php").on(server);
|
||||
|
||||
server.start();
|
||||
LOG.log(INFO,"Started webserver on port {0,number,#} …",port);
|
||||
|
||||
@@ -5,7 +5,7 @@ dependencies {
|
||||
implementation(project(":de.srsoftware.cal.base"))
|
||||
implementation(project(":de.srsoftware.cal.db"))
|
||||
|
||||
implementation("de.srsoftware:tools.http:1.2.2")
|
||||
implementation("de.srsoftware:tools.http:1.2.3")
|
||||
implementation("de.srsoftware:tools.optionals:1.0.0")
|
||||
implementation("de.srsoftware:tools.util:1.3.0")
|
||||
implementation("org.json:json:20240303")
|
||||
|
||||
@@ -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