-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sse: support method PUT/POST with body
Signed-off-by: neo <1100909+neowu@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
86 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core-ng/src/main/java/core/framework/internal/web/HTTPRequestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package core.framework.internal.web; | ||
|
||
import core.framework.internal.web.sse.ServerSentEventHandler; | ||
import io.undertow.server.HttpServerExchange; | ||
import io.undertow.util.HeaderMap; | ||
import io.undertow.util.HttpString; | ||
|
||
public class HTTPRequestHandler { | ||
final boolean sse; | ||
private final HttpServerExchange exchange; | ||
private final HTTPHandler handler; | ||
private final ServerSentEventHandler sseHandler; | ||
|
||
HTTPRequestHandler(HttpServerExchange exchange, HTTPHandler handler, ServerSentEventHandler sseHandler) { | ||
this.exchange = exchange; | ||
this.handler = handler; | ||
this.sseHandler = sseHandler; | ||
|
||
HttpString method = exchange.getRequestMethod(); | ||
String path = exchange.getRequestPath(); | ||
HeaderMap headers = exchange.getRequestHeaders(); | ||
sse = sseHandler != null && sseHandler.check(method, path, headers); | ||
} | ||
|
||
public void handle() { | ||
if (sse) { | ||
sseHandler.handleRequest(exchange); // not dispatch, continue in io thread | ||
} else { | ||
exchange.dispatch(handler); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters