Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added a check for websockets and switched back to jetty as the defaul…
…t implementation for until the own implementation is fully stable.
  • Loading branch information
JanHolger committed Dec 7, 2021
commit 11d4a67477062b71ec0c0eb05755bc12d3bfcf26
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>11.0.7</version>
<optional>true</optional>
<!-- <optional>true</optional> -->
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/javawebstack/httpserver/HTTPServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.javawebstack.abstractdata.AbstractMapper;
import org.javawebstack.abstractdata.NamingPolicy;
import org.javawebstack.httpserver.adapter.IHTTPSocketServer;
import org.javawebstack.httpserver.adapter.jetty.JettyHTTPSocketServer;
import org.javawebstack.httpserver.adapter.simple.SimpleHTTPSocketServer;
import org.javawebstack.httpserver.handler.*;
import org.javawebstack.httpserver.router.DefaultRouteAutoInjector;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class HTTPServer implements RouteParamTransformerProvider {
private Function<Class<?>, Object> controllerInitiator = this::defaultControllerInitiator;

public HTTPServer() {
this(new SimpleHTTPSocketServer());
this(new JettyHTTPSocketServer());
}

public HTTPServer(IHTTPSocketServer server) {
Expand Down Expand Up @@ -196,6 +197,8 @@ public HTTPServer afterAny(String pattern, AfterRequestHandler... handlers) {
}

public HTTPServer webSocket(String pattern, WebSocketHandler handler) {
if(!server.isWebSocketSupported())
throw new UnsupportedOperationException(server.getClass().getName() + " does not support websockets!");
return route(HTTPMethod.WEBSOCKET, pattern, new InternalWebSocketRequestHandler(handler));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public interface IHTTPSocketServer {
void stop();
void join();
void setHandler(IHTTPSocketHandler handler);
boolean isWebSocketSupported();

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ public void setHandler(IHTTPSocketHandler handler) {
this.handler = handler;
}

public boolean isWebSocketSupported() {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@ public void stop() {
} catch (IOException e) {}
}

public boolean isWebSocketSupported() {
return false;
}

}