Add some Http3 skeleton
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
EXAMPLE_FILES := Broadcast HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
||||
EXAMPLE_FILES := Http3Server Broadcast HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
||||
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
|
||||
override CXXFLAGS += -lpthread -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++2a -Isrc -IuSockets/src
|
||||
override LDFLAGS += uSockets/*.o -lz
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/* Do not rely on this API, it will change */
|
||||
#include "Http3App.h"
|
||||
#include <iostream>
|
||||
|
||||
/* Tentative example of simple Http3 server */
|
||||
int main() {
|
||||
uWS::QuicApp({
|
||||
.key_file_name = "../misc/key.pem",
|
||||
.cert_file_name = "../misc/cert.pem",
|
||||
.passphrase = "1234"
|
||||
}).get("/*", [](auto *res, auto */*req*/) {
|
||||
res->end("Hello quic!");
|
||||
}).listen(3000, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Listening on port " << 3000 << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
std::cout << "Failed to listen on port 3000" << std::endl;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "App.h"
|
||||
|
||||
#include "Http3Response.h"
|
||||
#include "Http3Request.h"
|
||||
#include "Http3Context.h"
|
||||
|
||||
namespace uWS {
|
||||
|
||||
struct QuicApp {
|
||||
Http3Context *http3Context;
|
||||
|
||||
QuicApp(SocketContextOptions options = {}) {
|
||||
/* Create the http3 context */
|
||||
http3Context = Http3Context::create((us_loop_t *)Loop::get(), options);
|
||||
}
|
||||
|
||||
QuicApp &listen(int port, std::function<void(void *)> cb) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
QuicApp &get(std::string path, std::function<void(Http3Response *, Http3Request *)> cb) {
|
||||
// http3Context->onHttp, internally using httprouter
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void run() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace uWS {
|
||||
struct Http3Context {
|
||||
static Http3Context *create(us_loop_t *loop, us_socket_context_options_t options) {
|
||||
return nullptr;
|
||||
|
||||
// call init here after setting the ext to Http3ContextData
|
||||
}
|
||||
|
||||
void init() {
|
||||
// set all callbacks here
|
||||
}
|
||||
|
||||
void onHttp() {
|
||||
// modifies the router we own as part of Http3ContextData, used in callbacks set in init
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace uWS {
|
||||
|
||||
struct Http3Request {
|
||||
// really the same thing as HttpRequest with same rules
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace uWS {
|
||||
|
||||
struct Http3Response {
|
||||
// has a quic stream
|
||||
|
||||
void end(std::string_view data) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user